diff --git a/.github/workflows/pypi-project.yml b/.github/workflows/pypi-project.yml index cd9d4b6..d5c953b 100644 --- a/.github/workflows/pypi-project.yml +++ b/.github/workflows/pypi-project.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] os: [ubuntu-latest, macos-latest, windows-latest] # if: startsWith(github.event.head_commit.message, 'bump:') == false steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index af6f63f..88a4ba2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ exclude: 'scripts/.*' repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: check-added-large-files - id: check-ast @@ -32,7 +32,6 @@ repos: - id: mixed-line-ending - id: requirements-txt-fixer - id: trailing-whitespace - - id: fix-encoding-pragma args: - --remove # - id: name-tests-test @@ -45,7 +44,7 @@ repos: # files: .pre-commit-config.yaml - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.15.0 + rev: v1.19.1 hooks: - id: mypy name: mypy @@ -61,27 +60,27 @@ repos: # files: ^(src/|tests/) - repo: https://github.com/PyCQA/isort - rev: 6.0.1 + rev: 7.0.0 hooks: - id: isort args: ["--profile", "black", "--filter-files", "--combine-as", "honor--noqa"] - repo: https://github.com/psf/black - rev: 25.1.0 + rev: 26.1.0 hooks: - id: black - language_version: python3.9 + language_version: python3.10 args: ["--skip-magic-trailing-comma"] - repo: https://github.com/asottile/pyupgrade - rev: v3.19.1 + rev: v3.21.2 hooks: - args: - - --py39-plus + - --py310-plus id: pyupgrade - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.5 + rev: v1.5.6 hooks: - id: remove-tabs @@ -133,7 +132,7 @@ repos: # C901 function is too complex # for iter_at_depth # PLR0912 too many branches # for iter_at_depth # - rev: 'v0.11.9' + rev: 'v0.14.14' hooks: - id: ruff exclude: "tests" @@ -145,6 +144,6 @@ repos: # reads pyproject.toml for additional config - repo: https://github.com/RobertCraigie/pyright-python - rev: v1.1.400 + rev: v1.1.408 hooks: - id: pyright diff --git a/docx2python/attribute_register.py b/docx2python/attribute_register.py index 34d93e7..e5012c0 100644 --- a/docx2python/attribute_register.py +++ b/docx2python/attribute_register.py @@ -16,12 +16,12 @@ import uuid import warnings from enum import Enum -from typing import TYPE_CHECKING, Callable, NamedTuple +from typing import TYPE_CHECKING, NamedTuple from lxml import etree if TYPE_CHECKING: - from collections.abc import Iterator + from collections.abc import Callable, Iterator from lxml.etree import _Element as EtreeElement # type: ignore diff --git a/docx2python/bullets_and_numbering.py b/docx2python/bullets_and_numbering.py index ffc6471..61c498e 100644 --- a/docx2python/bullets_and_numbering.py +++ b/docx2python/bullets_and_numbering.py @@ -19,12 +19,14 @@ import warnings from collections import defaultdict from contextlib import suppress -from typing import TYPE_CHECKING, Callable +from typing import TYPE_CHECKING from docx2python import numbering_formats as nums from docx2python.namespace import get_attrib_by_qn, iterfind_by_qn if TYPE_CHECKING: + from collections.abc import Callable + from lxml.etree import _Element as EtreeElement # type: ignore from docx2python.docx_context import NumIdAttrs diff --git a/pyproject.toml b/pyproject.toml index 92ba2fd..82acc6b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ [project] name = "docx2python" -version = "3.5.0" +version = "3.6.0" description = "Extract content from docx files" authors = [{ name = "Shay Hill", email = "shay_public@hotmail.com" }] license = {text = "MIT"} readme = "README.md" -requires-python = ">=3.9.0" +requires-python = ">=3.10.0" dependencies = ["lxml", "paragraphs", "typing_extensions", "types-lxml"] [project.optional-dependencies] @@ -19,7 +19,7 @@ build-backend = "setuptools.build_meta" [tool.commitizen] name = "cz_conventional_commits" -version = "3.5.0" +version = "3.6.0" tag_format = "$version" major-version-zero = true version_files = ["pyproject.toml:^version"] @@ -32,7 +32,7 @@ profile = "black" [tool.tox] legacy_tox_ini = """ [tox] -envlist = py{313,312,311,310,39} +envlist = py{314,313,312,311,310} [testenv] deps = pytest diff --git a/tests/test_comments.py b/tests/test_comments.py index 91b55fb..1469f9f 100644 --- a/tests/test_comments.py +++ b/tests/test_comments.py @@ -30,28 +30,22 @@ def test_comments() -> None: pars.close() assert comments == [ ( - par( - """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua.""" - ), + par("""Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do + eiusmod tempor incididunt ut labore et dolore magna aliqua."""), "Randy Bartels", "2024-03-28T17:22:00Z", "COMMENT", ), ( - par( - """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua.""" - ), + par("""Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do + eiusmod tempor incididunt ut labore et dolore magna aliqua."""), "Randy Bartels", "2024-03-28T17:22:00Z", "RESPONSE", ), ( - par( - """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua.""" - ), + par("""Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do + eiusmod tempor incididunt ut labore et dolore magna aliqua."""), "Shay Hill", "2024-03-29T12:10:00Z", "Response from Shay Hill", @@ -63,28 +57,22 @@ def test_comments() -> None: "Comment on subset starting with tempor", ), ( - par( - """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua.""" - ), + par("""Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do + eiusmod tempor incididunt ut labore et dolore magna aliqua."""), "Randy Bartels", "2024-03-28T17:22:00Z", "COMMENT on par 5", ), ( - par( - """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua.""" - ), + par("""Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do + eiusmod tempor incididunt ut labore et dolore magna aliqua."""), "Randy Bartels", "2024-03-28T17:22:00Z", "RESPONSE to comment on par 5", ), ( - par( - """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua.""" - ), + par("""Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do + eiusmod tempor incididunt ut labore et dolore magna aliqua."""), "Shay Hill", "2024-03-29T12:10:00Z", "Response from Shay Hill on par 5", @@ -190,8 +178,7 @@ def test_long_comment( "Amet ", "Randy Bartels", "2024-04-02T17:00:00Z", - par( - """Comment 6 with a long comment.\n\nmagna fringilla urna porttitor + par("""Comment 6 with a long comment.\n\nmagna fringilla urna porttitor rhoncus dolor purus non enim praesent elementum facilisis leo vel fringilla est ullamcorper eget nulla facilisi etiam dignissim diam quis enim lobortis scelerisque fermentum dui faucibus in ornare quam @@ -201,8 +188,7 @@ def test_long_comment( vitae congue eu consequat ac felis donec et odio pellentesque diam volutpat commodo sed egestas egestas fringilla phasellus faucibus scelerisque eleifend donec pretium vulputate sapien nec sagittis - aliquam malesuada bibendum""" - ), + aliquam malesuada bibendum"""), ) def test_comment_7( @@ -226,8 +212,7 @@ def test_long_response( "suspendisse ", "Randy Bartels", "2024-04-02T17:00:00Z", - par( - """Long response: magna fringilla urna porttitor rhoncus dolor purus + par("""Long response: magna fringilla urna porttitor rhoncus dolor purus non enim praesent elementum facilisis leo vel fringilla est ullamcorper eget nulla facilisi etiam dignissim diam quis enim lobortis scelerisque fermentum dui faucibus in ornare quam viverra @@ -237,8 +222,7 @@ def test_long_response( congue eu consequat ac felis donec et odio pellentesque diam volutpat commodo sed egestas egestas fringilla phasellus faucibus scelerisque eleifend donec pretium vulputate sapien nec sagittis aliquam - malesuada bibendum""" - ), + malesuada bibendum"""), ) def comment_8( diff --git a/tests/test_docx2python.py b/tests/test_docx2python.py index 34c56ed..6eca6b5 100644 --- a/tests/test_docx2python.py +++ b/tests/test_docx2python.py @@ -14,10 +14,8 @@ from docx2python.main import docx2python from tests.conftest import RESOURCES -ALT_TEXT = par( - """----Image alt text---->A close up of a logo\n\n - Description automatically generated<""" -) +ALT_TEXT = par("""----Image alt text---->A close up of a logo\n\n + Description automatically generated<""") class TestFormatting: @@ -52,10 +50,8 @@ def test_footnotes(self) -> None: [ "footnote2)\t", " Second footnote", - par( - """----Image alt text---->A close up of a - logo\n\nDescription automatically generated<""" - ), + par("""----Image alt text---->A close up of a + logo\n\nDescription automatically generated<"""), "----media/image1.png----", ] ], @@ -76,10 +72,8 @@ def test_endnotes(self) -> None: [ "endnote2)\t", " Second endnote", - par( - """----Image alt text---->A close up of a - logo\n\nDescription automatically generated<""" - ), + par("""----Image alt text---->A close up of a + logo\n\nDescription automatically generated<"""), "----media/image1.png----", ] ], @@ -202,10 +196,8 @@ def test_formatting_captured(self) -> None: 'Colored', 'Large Colored', 'Large Bold', - par( - """Large Bold Italics - Underlined""" - ), + par("""Large Bold Italics + Underlined"""), ] def test_paragraph_formatting(self) -> None: @@ -223,10 +215,8 @@ def test_paragraph_formatting(self) -> None: ["