From 786361353e7989718689b1c78dbdebadc25b2de4 Mon Sep 17 00:00:00 2001 From: skelmis Date: Sun, 15 Jun 2025 15:00:28 +1200 Subject: [PATCH 01/13] refactor: migrate project to uv --- .gitignore | 2 +- .python-version | 1 + pyproject.toml | 70 ++++++++++++++++++++++++++++--------------------- 3 files changed, 42 insertions(+), 31 deletions(-) create mode 100644 .python-version diff --git a/.gitignore b/.gitignore index f7133ae..e30b4d0 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ _scratch/ Session.vim /.tox/ .idea -poetry.lock +uv.lock !src/docx/templates/default.docx test.py diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..c8cfe39 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.10 diff --git a/pyproject.toml b/pyproject.toml index f371b33..ecb56ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,42 +1,52 @@ -[tool.poetry] +[project] name = "skelmis-docx" version = "2.2.0" description = "Create, read, and update Microsoft Word .docx files." -authors = ["Skelmis "] -license = "MIT" +authors = [{ name = "Skelmis", email = "skelmis.craft@gmail.com" }] +requires-python = "~=3.10" readme = "README.md" -packages = [{include = "skelmis/docx", from="src"}] +license = "MIT" +dependencies = [ + "lxml>=3.1.0", + "typing-extensions>=4.12.2,<5", + "pywin32==307 ; sys_platform == 'windows'", +] -#[project.urls] -#Homepage = "https://github.com/skelmis/python-docx" -#Documentation = "https://skelmis-docx.readthedocs.io/en/latest/" +[dependency-groups] +dev = [ + "build>=1.2.1,<2", + "ruff>=0.5.7,<0.6", + "setuptools>=72.2.0,<73", + "tox>=4.18.0,<5", + "twine>=5.1.1,<6", + "types-lxml>=2024.8.7,<2025", + "behave>=1.2.6,<2", + "pyparsing>=3.1.2,<4", + "pytest>=8.3.2,<9", + "pytest-coverage>=0.0,<0.1", + "pytest-xdist>=3.6.1,<4", + "black>=24.10.0,<25", +] +docs = ["sphinx>=8.0.2,<9"] + +[tool.uv] +default-groups = [ + "dev", + "docs", +] -[tool.poetry.dependencies] -python = "^3.10" -lxml = ">=3.1.0," -typing-extensions = "^4.12.2" -pywin32 = {version = "^307", platform = "windows"} +[tool.hatch.build.targets.sdist] +include = ["src/skelmis/docx"] -[tool.poetry.group.dev.dependencies] -build = "^1.2.1" -ruff = "^0.5.7" -setuptools = "^72.2.0" -tox = "^4.18.0" -twine = "^5.1.1" -types-lxml = "^2024.8.7" -behave = "^1.2.6" -pyparsing = "^3.1.2" -pytest = "^8.3.2" -pytest-coverage = "^0.0" -pytest-xdist = "^3.6.1" -black = "^24.10.0" +[tool.hatch.build.targets.wheel] +include = ["src/skelmis/docx"] -[tool.poetry.group.docs.dependencies] -sphinx = "^8.0.2" +[tool.hatch.build.targets.wheel.sources] +"src/skelmis/docx" = "skelmis/docx" [build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" +requires = ["hatchling"] +build-backend = "hatchling.build" [tool.black] line-length = 100 @@ -107,4 +117,4 @@ select = [ [tool.ruff.lint.isort] known-first-party = ["docx"] -known-local-folder = ["helpers"] \ No newline at end of file +known-local-folder = ["helpers"] From 4b7a6555978d4db52fb639042bb18fd8efb595f3 Mon Sep 17 00:00:00 2001 From: skelmis Date: Sun, 15 Jun 2025 15:08:51 +1200 Subject: [PATCH 02/13] Modify pyproject to contain relevant classifiers etc --- HISTORY.rst | 6 ++++++ pyproject.toml | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index a01b015..e1214ad 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,12 @@ Release History --------------- +2.2.1 (2025-06-15) +++++++++++++++++++ + +- Moves project from Poetry to uv +- Re-add's relevant pypi homepage links + 2.2.0 (2025-06-15) ++++++++++++++++++ diff --git a/pyproject.toml b/pyproject.toml index ecb56ad..883f12c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,11 +6,30 @@ authors = [{ name = "Skelmis", email = "skelmis.craft@gmail.com" }] requires-python = "~=3.10" readme = "README.md" license = "MIT" +keywords = ["Docx"] dependencies = [ "lxml>=3.1.0", "typing-extensions>=4.12.2,<5", "pywin32==307 ; sys_platform == 'windows'", ] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + + # Specify the Python versions you support here. + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] + +[project.urls] +Homepage = "https://github.com/skelmis/python-docx" +Documentation = "https://skelmis-docx.readthedocs.io/en/latest/" +"Issue tracker" = "https://github.com/Skelmis/python-docx/issues" +Changelog = "https://github.com/Skelmis/python-docx/blob/master/HISTORY.rst" + [dependency-groups] dev = [ From a8fb3a18366d3eb3b421a4125bca7274a8a03e6b Mon Sep 17 00:00:00 2001 From: skelmis Date: Sun, 15 Jun 2025 15:13:44 +1200 Subject: [PATCH 03/13] Move actions to uv --- .github/actions/setup-poetry/action.yml | 46 ------------------------- .github/workflows/pipeline.yml | 27 ++++++++------- 2 files changed, 15 insertions(+), 58 deletions(-) delete mode 100644 .github/actions/setup-poetry/action.yml diff --git a/.github/actions/setup-poetry/action.yml b/.github/actions/setup-poetry/action.yml deleted file mode 100644 index f6fef80..0000000 --- a/.github/actions/setup-poetry/action.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: 'setup-poetry' -description: 'Setup Poetry Project' - -#---------------------------------------------- -# following the steps outlined at -# https://github.com/snok/install-poetry?tab=readme-ov-file#testing -#---------------------------------------------- - -runs: - using: 'composite' - steps: - #---------------------------------------------- - # install & configure poetry - #---------------------------------------------- - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - version: 1.8.5 - virtualenvs-create: true - virtualenvs-in-project: true - installer-parallel: true - - #---------------------------------------------- - # load cached venv if cache exists - #---------------------------------------------- - - name: Load cached venv - id: cached-poetry-dependencies - uses: actions/cache@v4 - with: - path: .venv - key: venv-${{ runner.name }}-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} - - #---------------------------------------------- - # install dependencies if cache does not exist - #---------------------------------------------- - - name: Install dependencies - if: steps.cached--dependencies.outputs.cache-hit != 'true' - run: poetry install --no-interaction --no-root - shell: bash - - #---------------------------------------------- - # install your root project, if required - #---------------------------------------------- - - name: Install project - run: poetry install --no-interaction - shell: bash diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index ee09732..6110771 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -16,13 +16,15 @@ jobs: steps: - name: Check out repository uses: actions/checkout@v4 - - name: Set up python - id: setup-python + - name: Install uv + uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + version: "0.7.13" + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} - - name: Setup Poetry - uses: ./.github/actions/setup-poetry + python-version-file: ${{ matrix.python-version }} - name: Behave id: behave run: | @@ -38,15 +40,16 @@ jobs: steps: - name: Check out repository uses: actions/checkout@v4 - - name: Set up python - id: setup-python + - name: Install uv + uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + version: "0.7.13" + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} - - name: Setup Poetry - uses: ./.github/actions/setup-poetry + python-version-file: ${{ matrix.python-version }} - name: Run Pytest id: pytest run: | - source .venv/bin/activate - pytest tests/ + uv run pytest tests/ From b047ec16bc6a219c62d7efb329175f2ba14d40ac Mon Sep 17 00:00:00 2001 From: skelmis Date: Sun, 15 Jun 2025 15:16:15 +1200 Subject: [PATCH 04/13] Move actions to uv --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 883f12c..869e350 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "skelmis-docx" version = "2.2.0" description = "Create, read, and update Microsoft Word .docx files." authors = [{ name = "Skelmis", email = "skelmis.craft@gmail.com" }] -requires-python = "~=3.10" +requires-python = ">=3.10" readme = "README.md" license = "MIT" keywords = ["Docx"] From f5a5edd9092b0b806f3bd9fa12ef8104ed37f7c1 Mon Sep 17 00:00:00 2001 From: skelmis Date: Sun, 15 Jun 2025 15:16:50 +1200 Subject: [PATCH 05/13] Remove python version from repo and allow end devs inline with pyproject --- .gitignore | 1 + .python-version | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 .python-version diff --git a/.gitignore b/.gitignore index e30b4d0..57dad88 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ Session.vim /.tox/ .idea uv.lock +.python-version !src/docx/templates/default.docx test.py diff --git a/.python-version b/.python-version deleted file mode 100644 index c8cfe39..0000000 --- a/.python-version +++ /dev/null @@ -1 +0,0 @@ -3.10 From 30a5d7f72b8392d16f7386840bd5d0fda9008ff0 Mon Sep 17 00:00:00 2001 From: skelmis Date: Sun, 15 Jun 2025 15:17:38 +1200 Subject: [PATCH 06/13] Fix action version binding --- .github/workflows/pipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 6110771..c919146 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -24,7 +24,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version-file: ${{ matrix.python-version }} + python-version: ${{ matrix.python-version }} - name: Behave id: behave run: | @@ -48,7 +48,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version-file: ${{ matrix.python-version }} + python-version: ${{ matrix.python-version }} - name: Run Pytest id: pytest run: | From 5b934be6e8c7b2f11bc720c28fc1157037dc3ff3 Mon Sep 17 00:00:00 2001 From: skelmis Date: Sun, 15 Jun 2025 15:18:34 +1200 Subject: [PATCH 07/13] Fix behave action python venv --- .github/workflows/pipeline.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index c919146..25b5c29 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -28,9 +28,7 @@ jobs: - name: Behave id: behave run: | - source .venv/bin/activate - echo "Running tox with python version $PYTHON_VERSION" - behave + uv run behave pytest: runs-on: ubuntu-latest From dc6a665fd3924c86523bf2d45579ce97d14e38a0 Mon Sep 17 00:00:00 2001 From: skelmis Date: Sun, 15 Jun 2025 15:19:24 +1200 Subject: [PATCH 08/13] Limit push pipeline to master branch --- .github/workflows/pipeline.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 25b5c29..b2cf31c 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -3,6 +3,7 @@ name: Pipeline on: push: branches: + - master tags: pull_request: branches: From 7f2c90cee3029fa3c449635c3e8527149254cbf5 Mon Sep 17 00:00:00 2001 From: skelmis Date: Sun, 15 Jun 2025 15:28:58 +1200 Subject: [PATCH 09/13] Bump version and setup trusted publishing --- .github/workflows/release.yml | 26 ++++++++++++++++++++++++++ pyproject.toml | 2 +- src/skelmis/docx/__init__.py | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..977501f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +on: + push: + tags: + - 'v*' + +jobs: + pypi-publish: + name: upload release to PyPI + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write + steps: + - uses: actions/checkout@v4 + + - name: Install uv and setup the python version + uses: astral-sh/setup-uv@v5 + + - name: Install the project + run: uv sync --all-groups + + - name: Build wheel + run: uv build + + - name: Publish package + run: uv publish diff --git a/pyproject.toml b/pyproject.toml index 869e350..53d0127 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "skelmis-docx" -version = "2.2.0" +version = "2.2.1" description = "Create, read, and update Microsoft Word .docx files." authors = [{ name = "Skelmis", email = "skelmis.craft@gmail.com" }] requires-python = ">=3.10" diff --git a/src/skelmis/docx/__init__.py b/src/skelmis/docx/__init__.py index 6cbec7a..ce02ca2 100644 --- a/src/skelmis/docx/__init__.py +++ b/src/skelmis/docx/__init__.py @@ -13,7 +13,7 @@ if TYPE_CHECKING: from skelmis.docx.opc.part import Part -__version__ = "2.2.0" +__version__ = "2.2.1" __all__ = ["Document"] From 3e319ce7566d7275874b2371d544d1868fb05302 Mon Sep 17 00:00:00 2001 From: skelmis Date: Sun, 15 Jun 2025 15:29:56 +1200 Subject: [PATCH 10/13] Remove all groups flag, no optional deps in builds --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 977501f..b0122db 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: uses: astral-sh/setup-uv@v5 - name: Install the project - run: uv sync --all-groups + run: uv sync - name: Build wheel run: uv build From acd3598e4296c2a4188a8a30d10bef32d5b79b8e Mon Sep 17 00:00:00 2001 From: skelmis Date: Sun, 15 Jun 2025 15:30:11 +1200 Subject: [PATCH 11/13] Revert last commit --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b0122db..977501f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: uses: astral-sh/setup-uv@v5 - name: Install the project - run: uv sync + run: uv sync --all-groups - name: Build wheel run: uv build From 4651878e9883cff3dfed3033edff1133068f5c18 Mon Sep 17 00:00:00 2001 From: skelmis Date: Sun, 15 Jun 2025 15:37:25 +1200 Subject: [PATCH 12/13] Bump deps and bring project inline with new black and ruff spec --- pyproject.toml | 13 ++- src/skelmis/docx/document.py | 2 +- src/skelmis/docx/image/__init__.py | 2 +- src/skelmis/docx/image/constants.py | 128 +++++++++++++-------------- src/skelmis/docx/image/jpeg.py | 19 ++-- src/skelmis/docx/opc/rel.py | 2 +- src/skelmis/docx/oxml/__init__.py | 20 ++--- src/skelmis/docx/oxml/numbering.py | 12 +-- src/skelmis/docx/oxml/shared.py | 2 +- src/skelmis/docx/oxml/table.py | 2 +- src/skelmis/docx/oxml/text/font.py | 4 +- src/skelmis/docx/oxml/xmlchemy.py | 4 +- src/skelmis/docx/parts/story.py | 2 +- src/skelmis/docx/styles/styles.py | 6 +- src/skelmis/docx/text/paragraph.py | 37 +++++--- src/skelmis/docx/text/run.py | 2 +- src/skelmis/docx/utility/__init__.py | 2 +- tests/image/test_bmp.py | 4 +- tests/image/test_gif.py | 2 +- tests/image/test_helpers.py | 4 +- tests/image/test_jpeg.py | 8 +- tests/image/test_png.py | 4 +- tests/image/test_tiff.py | 6 +- 23 files changed, 147 insertions(+), 140 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 53d0127..603a5e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,17 +34,17 @@ Changelog = "https://github.com/Skelmis/python-docx/blob/master/HISTORY.rst" [dependency-groups] dev = [ "build>=1.2.1,<2", - "ruff>=0.5.7,<0.6", - "setuptools>=72.2.0,<73", + "ruff>=0.11.13", + "setuptools>=80.9.0", "tox>=4.18.0,<5", - "twine>=5.1.1,<6", - "types-lxml>=2024.8.7,<2025", + "twine>=6.1.0", + "types-lxml>=2024.8.7", "behave>=1.2.6,<2", "pyparsing>=3.1.2,<4", "pytest>=8.3.2,<9", "pytest-coverage>=0.0,<0.1", "pytest-xdist>=3.6.1,<4", - "black>=24.10.0,<25", + "black>=25.1.0", ] docs = ["sphinx>=8.0.2,<9"] @@ -110,14 +110,13 @@ python_functions = ["it_", "its_", "they_", "and_", "but_"] [tool.ruff] exclude = [] -line-length = 100 +line-length = 125 target-version = "py310" [tool.ruff.lint] ignore = [ "COM812", # -- over-aggressively insists on trailing commas where not desired -- "PT001", # -- wants @pytest.fixture() instead of @pytest.fixture -- - "PT005", # -- wants @pytest.fixture() instead of @pytest.fixture -- ] select = [ "C4", # -- flake8-comprehensions -- diff --git a/src/skelmis/docx/document.py b/src/skelmis/docx/document.py index fd56b89..25d82e4 100644 --- a/src/skelmis/docx/document.py +++ b/src/skelmis/docx/document.py @@ -51,7 +51,7 @@ def configure_styles_for_numbered_lists(self): STYP = skelmis.docx.enum.style.WD_STYLE_TYPE num_xml = self.part.numbering_part.element next_abstract_id = max([J.abstractNumId for J in num_xml.abstractNum_lst]) + 1 - l = num_xml._new_abstractNum() + l = num_xml._new_abstractNum() # noqa: E741 l.abstractNumId = next_abstract_id l.add_multiLevelType().val = "multilevel" diff --git a/src/skelmis/docx/image/__init__.py b/src/skelmis/docx/image/__init__.py index 9d28a87..9334472 100644 --- a/src/skelmis/docx/image/__init__.py +++ b/src/skelmis/docx/image/__init__.py @@ -12,7 +12,7 @@ SIGNATURES = ( # class, offset, signature_bytes - (Png, 0, b"\x89PNG\x0D\x0A\x1A\x0A"), + (Png, 0, b"\x89PNG\x0d\x0a\x1a\x0a"), (Jfif, 6, b"JFIF"), (Exif, 6, b"Exif"), (Gif, 0, b"GIF87a"), diff --git a/src/skelmis/docx/image/constants.py b/src/skelmis/docx/image/constants.py index 729a828..03fae58 100644 --- a/src/skelmis/docx/image/constants.py +++ b/src/skelmis/docx/image/constants.py @@ -5,58 +5,58 @@ class JPEG_MARKER_CODE: """JPEG marker codes.""" TEM = b"\x01" - DHT = b"\xC4" - DAC = b"\xCC" - JPG = b"\xC8" - - SOF0 = b"\xC0" - SOF1 = b"\xC1" - SOF2 = b"\xC2" - SOF3 = b"\xC3" - SOF5 = b"\xC5" - SOF6 = b"\xC6" - SOF7 = b"\xC7" - SOF9 = b"\xC9" - SOFA = b"\xCA" - SOFB = b"\xCB" - SOFD = b"\xCD" - SOFE = b"\xCE" - SOFF = b"\xCF" - - RST0 = b"\xD0" - RST1 = b"\xD1" - RST2 = b"\xD2" - RST3 = b"\xD3" - RST4 = b"\xD4" - RST5 = b"\xD5" - RST6 = b"\xD6" - RST7 = b"\xD7" - - SOI = b"\xD8" - EOI = b"\xD9" - SOS = b"\xDA" - DQT = b"\xDB" # Define Quantization Table(s) - DNL = b"\xDC" - DRI = b"\xDD" - DHP = b"\xDE" - EXP = b"\xDF" - - APP0 = b"\xE0" - APP1 = b"\xE1" - APP2 = b"\xE2" - APP3 = b"\xE3" - APP4 = b"\xE4" - APP5 = b"\xE5" - APP6 = b"\xE6" - APP7 = b"\xE7" - APP8 = b"\xE8" - APP9 = b"\xE9" - APPA = b"\xEA" - APPB = b"\xEB" - APPC = b"\xEC" - APPD = b"\xED" - APPE = b"\xEE" - APPF = b"\xEF" + DHT = b"\xc4" + DAC = b"\xcc" + JPG = b"\xc8" + + SOF0 = b"\xc0" + SOF1 = b"\xc1" + SOF2 = b"\xc2" + SOF3 = b"\xc3" + SOF5 = b"\xc5" + SOF6 = b"\xc6" + SOF7 = b"\xc7" + SOF9 = b"\xc9" + SOFA = b"\xca" + SOFB = b"\xcb" + SOFD = b"\xcd" + SOFE = b"\xce" + SOFF = b"\xcf" + + RST0 = b"\xd0" + RST1 = b"\xd1" + RST2 = b"\xd2" + RST3 = b"\xd3" + RST4 = b"\xd4" + RST5 = b"\xd5" + RST6 = b"\xd6" + RST7 = b"\xd7" + + SOI = b"\xd8" + EOI = b"\xd9" + SOS = b"\xda" + DQT = b"\xdb" # Define Quantization Table(s) + DNL = b"\xdc" + DRI = b"\xdd" + DHP = b"\xde" + EXP = b"\xdf" + + APP0 = b"\xe0" + APP1 = b"\xe1" + APP2 = b"\xe2" + APP3 = b"\xe3" + APP4 = b"\xe4" + APP5 = b"\xe5" + APP6 = b"\xe6" + APP7 = b"\xe7" + APP8 = b"\xe8" + APP9 = b"\xe9" + APPA = b"\xea" + APPB = b"\xeb" + APPC = b"\xec" + APPD = b"\xed" + APPE = b"\xee" + APPF = b"\xef" STANDALONE_MARKERS = (TEM, SOI, EOI, RST0, RST1, RST2, RST3, RST4, RST5, RST6, RST7) @@ -78,18 +78,18 @@ class JPEG_MARKER_CODE: marker_names = { b"\x00": "UNKNOWN", - b"\xC0": "SOF0", - b"\xC2": "SOF2", - b"\xC4": "DHT", - b"\xDA": "SOS", # start of scan - b"\xD8": "SOI", # start of image - b"\xD9": "EOI", # end of image - b"\xDB": "DQT", - b"\xE0": "APP0", - b"\xE1": "APP1", - b"\xE2": "APP2", - b"\xED": "APP13", - b"\xEE": "APP14", + b"\xc0": "SOF0", + b"\xc2": "SOF2", + b"\xc4": "DHT", + b"\xda": "SOS", # start of scan + b"\xd8": "SOI", # start of image + b"\xd9": "EOI", # end of image + b"\xdb": "DQT", + b"\xe0": "APP0", + b"\xe1": "APP1", + b"\xe2": "APP2", + b"\xed": "APP13", + b"\xee": "APP14", } @classmethod diff --git a/src/skelmis/docx/image/jpeg.py b/src/skelmis/docx/image/jpeg.py index e32627f..7311791 100644 --- a/src/skelmis/docx/image/jpeg.py +++ b/src/skelmis/docx/image/jpeg.py @@ -188,20 +188,20 @@ def next(self, start): def _next_non_ff_byte(self, start): """Return an offset, byte 2-tuple for the next byte in `stream` that is not - '\xFF', starting with the byte at offset `start`. + '\xff', starting with the byte at offset `start`. - If the byte at offset `start` is not '\xFF', `start` and the returned `offset` + If the byte at offset `start` is not '\xff', `start` and the returned `offset` will be the same. """ self._stream.seek(start) byte_ = self._read_byte() - while byte_ == b"\xFF": + while byte_ == b"\xff": byte_ = self._read_byte() offset_of_non_ff_byte = self._stream.tell() - 1 return offset_of_non_ff_byte, byte_ def _offset_of_next_ff_byte(self, start): - """Return the offset of the next '\xFF' byte in `stream` starting with the byte + """Return the offset of the next '\xff' byte in `stream` starting with the byte at offset `start`. Returns `start` if the byte at that offset is a hex 255; it does not necessarily @@ -209,7 +209,7 @@ def _offset_of_next_ff_byte(self, start): """ self._stream.seek(start) byte_ = self._read_byte() - while byte_ != b"\xFF": + while byte_ != b"\xff": byte_ = self._read_byte() offset_of_ff_byte = self._stream.tell() - 1 return offset_of_ff_byte @@ -255,15 +255,14 @@ def __init__(self, marker_code, offset, segment_length): def from_stream(cls, stream, marker_code, offset): """Return a generic |_Marker| instance for the marker at `offset` in `stream` having `marker_code`.""" - if JPEG_MARKER_CODE.is_standalone(marker_code): - segment_length = 0 - else: - segment_length = stream.read_short(offset) + segment_length = ( + 0 if JPEG_MARKER_CODE.is_standalone(marker_code) else stream.read_short(offset) + ) return cls(marker_code, offset, segment_length) @property def marker_code(self): - """The single-byte code that identifies the type of this marker, e.g. ``'\xE0'`` + """The single-byte code that identifies the type of this marker, e.g. ``'\xe0'`` for start of image (SOI).""" return self._marker_code diff --git a/src/skelmis/docx/opc/rel.py b/src/skelmis/docx/opc/rel.py index 4a1d5d6..64e3587 100644 --- a/src/skelmis/docx/opc/rel.py +++ b/src/skelmis/docx/opc/rel.py @@ -79,7 +79,7 @@ def matches(rel: _Relationship, reltype: str, target: Part | str, is_external: b if rel.is_external != is_external: return False rel_target = rel.target_ref if rel.is_external else rel.target_part - if rel_target != target: + if rel_target != target: # noqa: SIM103 return False return True diff --git a/src/skelmis/docx/oxml/__init__.py b/src/skelmis/docx/oxml/__init__.py index 9e261e9..7ace740 100644 --- a/src/skelmis/docx/oxml/__init__.py +++ b/src/skelmis/docx/oxml/__init__.py @@ -22,7 +22,7 @@ CT_ShapeProperties, CT_Transform2D, ) -from skelmis.docx.oxml.shared import CT_DecimalNumber, CT_OnOff, CT_String, CT_LongHexNumber +from skelmis.docx.oxml.shared import CT_DecimalNumber, CT_LongHexNumber, CT_OnOff, CT_String from skelmis.docx.oxml.text.hyperlink import CT_Hyperlink from skelmis.docx.oxml.text.pagebreak import CT_LastRenderedPageBreak from skelmis.docx.oxml.text.run import ( @@ -93,19 +93,19 @@ register_element_cls("w:body", CT_Body) register_element_cls("w:document", CT_Document) -from .numbering import ( +from .numbering import ( # noqa: E402 + CT_AbstractNum, + CT_LevelSuffix, + CT_LevelText, + CT_Lvl, + CT_LvlLegacy, + CT_MultiLevelType, CT_Num, CT_Numbering, - CT_NumLvl, - CT_NumPr, - CT_LevelSuffix, CT_NumFmt, - CT_MultiLevelType, - CT_LvlLegacy, - CT_LevelText, + CT_NumLvl, CT_NumPicBullet, - CT_Lvl, - CT_AbstractNum, + CT_NumPr, ) register_element_cls("w:abstractNumId", CT_DecimalNumber) diff --git a/src/skelmis/docx/oxml/numbering.py b/src/skelmis/docx/oxml/numbering.py index 5bd1934..7f087e0 100644 --- a/src/skelmis/docx/oxml/numbering.py +++ b/src/skelmis/docx/oxml/numbering.py @@ -5,22 +5,22 @@ from skelmis.docx.oxml.simpletypes import ( ST_DecimalNumber, ST_LevelSuffix, + ST_LongHexNumber, + ST_MultiLevelType, ST_NumberFormat, + ST_OnOff, + ST_SignedTwipsMeasure, ST_String, - ST_MultiLevelType, ST_TwipsMeasure, - ST_SignedTwipsMeasure, - ST_OnOff, - ST_LongHexNumber, ) from skelmis.docx.oxml.xmlchemy import ( BaseOxmlElement, + Choice, OneAndOnlyOne, + OptionalAttribute, RequiredAttribute, ZeroOrMore, ZeroOrOne, - OptionalAttribute, - Choice, ) diff --git a/src/skelmis/docx/oxml/shared.py b/src/skelmis/docx/oxml/shared.py index 4219139..372530c 100644 --- a/src/skelmis/docx/oxml/shared.py +++ b/src/skelmis/docx/oxml/shared.py @@ -6,7 +6,7 @@ from skelmis.docx.oxml.ns import qn from skelmis.docx.oxml.parser import OxmlElement -from skelmis.docx.oxml.simpletypes import ST_DecimalNumber, ST_OnOff, ST_String, ST_LongHexNumber +from skelmis.docx.oxml.simpletypes import ST_DecimalNumber, ST_LongHexNumber, ST_OnOff, ST_String from skelmis.docx.oxml.xmlchemy import BaseOxmlElement, OptionalAttribute, RequiredAttribute diff --git a/src/skelmis/docx/oxml/table.py b/src/skelmis/docx/oxml/table.py index 36ae7f5..c4ab013 100644 --- a/src/skelmis/docx/oxml/table.py +++ b/src/skelmis/docx/oxml/table.py @@ -613,7 +613,7 @@ def _is_empty(self) -> bool: # -- cell must include at least one block item but can be a `w:tbl`, `w:sdt`, # -- `w:customXml` or a `w:p` only_item = block_items[0] - if isinstance(only_item, CT_P) and len(only_item.r_lst) == 0: + if isinstance(only_item, CT_P) and len(only_item.r_lst) == 0: # noqa: SIM103 return True return False diff --git a/src/skelmis/docx/oxml/text/font.py b/src/skelmis/docx/oxml/text/font.py index 38e1da2..cc1b0cf 100644 --- a/src/skelmis/docx/oxml/text/font.py +++ b/src/skelmis/docx/oxml/text/font.py @@ -253,7 +253,7 @@ def subscript(self) -> bool | None: vertAlign = self.vertAlign if vertAlign is None: return None - if vertAlign.val == ST_VerticalAlignRun.SUBSCRIPT: + if vertAlign.val == ST_VerticalAlignRun.SUBSCRIPT: # noqa: SIM103 return True return False @@ -277,7 +277,7 @@ def superscript(self) -> bool | None: vertAlign = self.vertAlign if vertAlign is None: return None - if vertAlign.val == ST_VerticalAlignRun.SUPERSCRIPT: + if vertAlign.val == ST_VerticalAlignRun.SUPERSCRIPT: # noqa: SIM103 return True return False diff --git a/src/skelmis/docx/oxml/xmlchemy.py b/src/skelmis/docx/oxml/xmlchemy.py index bf6a225..b40dcc4 100644 --- a/src/skelmis/docx/oxml/xmlchemy.py +++ b/src/skelmis/docx/oxml/xmlchemy.py @@ -57,7 +57,7 @@ def __eq__(self, other: object) -> bool: lines_other = other.splitlines() if len(lines) != len(lines_other): return False - for line, line_other in zip(lines, lines_other): + for line, line_other in zip(lines, lines_other): # noqa: SIM110 if not self._eq_elm_strs(line, line_other): return False return True @@ -85,7 +85,7 @@ def _eq_elm_strs(self, line: str, line_2: str): return False if close != close_2: return False - if text != text_2: + if text != text_2: # noqa: SIM103 return False return True diff --git a/src/skelmis/docx/parts/story.py b/src/skelmis/docx/parts/story.py index a3e8273..4a3bd35 100644 --- a/src/skelmis/docx/parts/story.py +++ b/src/skelmis/docx/parts/story.py @@ -6,7 +6,7 @@ from skelmis.docx.opc.constants import RELATIONSHIP_TYPE as RT from skelmis.docx.opc.part import XmlPart -from skelmis.docx.oxml.shape import CT_Inline, CT_Anchor +from skelmis.docx.oxml.shape import CT_Anchor, CT_Inline from skelmis.docx.shared import Length, lazyproperty if TYPE_CHECKING: diff --git a/src/skelmis/docx/styles/styles.py b/src/skelmis/docx/styles/styles.py index ae27676..a42b228 100644 --- a/src/skelmis/docx/styles/styles.py +++ b/src/skelmis/docx/styles/styles.py @@ -12,11 +12,11 @@ from skelmis.docx.styles.latent import LatentStyles from skelmis.docx.styles.style import ( BaseStyle, - StyleFactory, - ParagraphStyle, CharacterStyle, - _TableStyle, + ParagraphStyle, + StyleFactory, _NumberingStyle, + _TableStyle, ) diff --git a/src/skelmis/docx/text/paragraph.py b/src/skelmis/docx/text/paragraph.py index 21e28a4..0e12aad 100644 --- a/src/skelmis/docx/text/paragraph.py +++ b/src/skelmis/docx/text/paragraph.py @@ -5,13 +5,13 @@ from typing import TYPE_CHECKING, Iterator, List, cast from skelmis.docx.enum.style import WD_STYLE_TYPE -from skelmis.docx.enum.text import WD_TAB_LEADER, WD_TAB_ALIGNMENT +from skelmis.docx.enum.text import WD_TAB_ALIGNMENT, WD_TAB_LEADER from skelmis.docx.opc.constants import RELATIONSHIP_TYPE from skelmis.docx.opc.oxml import BaseOxmlElement from skelmis.docx.oxml import OxmlElement from skelmis.docx.oxml.ns import qn from skelmis.docx.oxml.text.run import CT_R -from skelmis.docx.shared import StoryChild, Length +from skelmis.docx.shared import Length, StoryChild from skelmis.docx.styles.style import ParagraphStyle from skelmis.docx.text.hyperlink import Hyperlink from skelmis.docx.text.pagebreak import RenderedPageBreak @@ -49,14 +49,22 @@ def insert_table_of_contents( Insert a blank table of contents. :param levels: Number of headings to include. Default is 3. - :param starting_level: Starting heading level, useful if you want to only do say second heading levels and up. Default is 1. + :param starting_level: Starting heading level, useful if you want to only do say second + heading levels and up. Default is 1. :param format_table_as_links: If true, ToC entries are hyperlinks to within the document. - :param toc_width: The width of the table of contents. This essentially tells Word how much space between the ToC content and the page number. The default value is usually fine. + :param toc_width: The width of the table of contents. + This essentially tells Word how much space between the ToC + content and the page number. The default value is usually fine. :param show_page_numbers: If false, don't include page numbers within the toc. - :param hide_page_numbers_for_heading_range: Only show page numbers for headings outside of this range. Format is -, i.e. 2-5 to only show page numbers for first level headings. ``show_page_numbers`` must be ``True`` for this setting to work. + :param hide_page_numbers_for_heading_range: Only show page numbers for headings + outside of this range. Format is -, i.e. 2-5 to only show + page numbers for first level headings. ``show_page_numbers`` must be + ``True`` for this setting to work. :param fill_space_with: How to fill the remaining space on a line. Referred to technically as the tab stops. :param hide_tab_leader_and_page_numbers_in_web_layout_view: Hides tab leader and page numbers in Web layout view. - :param styles: The paragraph styles to use instead of the built-in ones. Format is list[tuple[int(HeadingLevel), str(StyleName)]]. N.b this field follows the spec, but is not tested for correctness currently. + :param styles: The paragraph styles to use instead of the built-in ones. + Format is list[tuple[int(HeadingLevel), str(StyleName)]]. N.b this field follows the spec, + but is not tested for correctness currently. Derived from the following comment: https://github.com/python-openxml/python-docx/issues/36#issuecomment-2739396561 @@ -147,9 +155,10 @@ def insert_table_of_contents( t_flag = f"\\t \"{','.join(entries)}\"" - items[-1][ - 0 - ].text = f' TOC \\o "{starting_level}-{levels}" {format_table_as_links} {t_flag} {z_flag} {n_flag} \\u ' + items[-1][0].text = ( + f' TOC \\o "{starting_level}-{levels}" {format_table_as_links} ' + f"{t_flag} {z_flag} {n_flag} \\u " + ) # items += [[OxmlElement("w:fldChar", attrs={qn("w:fldCharType"): "separate"})]] # @@ -225,7 +234,7 @@ def add_external_hyperlink( rPr = OxmlElement("w:rPr") # Add color if it is given - if not color is None: + if color is not None: c = OxmlElement("w:color") c.set(qn("w:val"), color) rPr.append(c) @@ -311,7 +320,7 @@ def _draw_bounding_line( "w:pPrChange", ) if top: - top_s = OxmlElement(f"w:top") + top_s = OxmlElement("w:top") top_s.set(qn("w:val"), "single") top_s.set(qn("w:sz"), "6") top_s.set(qn("w:space"), "1") @@ -319,7 +328,7 @@ def _draw_bounding_line( pBdr.append(top_s) if bottom: - bottom_s = OxmlElement(f"w:bottom") + bottom_s = OxmlElement("w:bottom") bottom_s.set(qn("w:val"), "single") bottom_s.set(qn("w:sz"), "6") bottom_s.set(qn("w:space"), "1") @@ -327,7 +336,7 @@ def _draw_bounding_line( pBdr.append(bottom_s) if left: - left_s = OxmlElement(f"w:left") + left_s = OxmlElement("w:left") left_s.set(qn("w:val"), "single") left_s.set(qn("w:sz"), "6") left_s.set(qn("w:space"), "1") @@ -335,7 +344,7 @@ def _draw_bounding_line( pBdr.append(left_s) if right: - right_s = OxmlElement(f"w:right") + right_s = OxmlElement("w:right") right_s.set(qn("w:val"), "single") right_s.set(qn("w:sz"), "6") right_s.set(qn("w:space"), "1") diff --git a/src/skelmis/docx/text/run.py b/src/skelmis/docx/text/run.py index 2bbd6ca..4d36247 100644 --- a/src/skelmis/docx/text/run.py +++ b/src/skelmis/docx/text/run.py @@ -11,7 +11,7 @@ from skelmis.docx.oxml.drawing import CT_Drawing from skelmis.docx.oxml.text.pagebreak import CT_LastRenderedPageBreak from skelmis.docx.shape import InlineShape -from skelmis.docx.shared import StoryChild, Inches, Pt +from skelmis.docx.shared import Inches, Pt, StoryChild from skelmis.docx.styles.style import CharacterStyle from skelmis.docx.text.font import Font from skelmis.docx.text.pagebreak import RenderedPageBreak diff --git a/src/skelmis/docx/utility/__init__.py b/src/skelmis/docx/utility/__init__.py index 359f49f..50f78f8 100644 --- a/src/skelmis/docx/utility/__init__.py +++ b/src/skelmis/docx/utility/__init__.py @@ -1,3 +1,3 @@ -from .to_pdf import update_toc, export_libre_macro, document_to_pdf +from .to_pdf import document_to_pdf, export_libre_macro, update_toc __all__ = ("update_toc", "export_libre_macro", "document_to_pdf") diff --git a/tests/image/test_bmp.py b/tests/image/test_bmp.py index eca5bcf..2ea0322 100644 --- a/tests/image/test_bmp.py +++ b/tests/image/test_bmp.py @@ -14,8 +14,8 @@ class DescribeBmp: def it_can_construct_from_a_bmp_stream(self, Bmp__init__): cx, cy, horz_dpi, vert_dpi = 26, 43, 200, 96 bytes_ = ( - b"fillerfillerfiller\x1A\x00\x00\x00\x2B\x00\x00\x00" - b"fillerfiller\xB8\x1E\x00\x00\x00\x00\x00\x00" + b"fillerfillerfiller\x1a\x00\x00\x00\x2b\x00\x00\x00" + b"fillerfiller\xb8\x1e\x00\x00\x00\x00\x00\x00" ) stream = io.BytesIO(bytes_) diff --git a/tests/image/test_gif.py b/tests/image/test_gif.py index ee12eed..71faf70 100644 --- a/tests/image/test_gif.py +++ b/tests/image/test_gif.py @@ -13,7 +13,7 @@ class DescribeGif: def it_can_construct_from_a_gif_stream(self, Gif__init__): cx, cy = 42, 24 - bytes_ = b"filler\x2A\x00\x18\x00" + bytes_ = b"filler\x2a\x00\x18\x00" stream = io.BytesIO(bytes_) gif = Gif.from_stream(stream) diff --git a/tests/image/test_helpers.py b/tests/image/test_helpers.py index 878341d..ab8546b 100644 --- a/tests/image/test_helpers.py +++ b/tests/image/test_helpers.py @@ -28,8 +28,8 @@ def it_can_read_a_long(self, read_long_fixture): @pytest.fixture( params=[ - (BIG_ENDIAN, b"\xBE\x00\x00\x00\x2A\xEF", 1, 42), - (LITTLE_ENDIAN, b"\xBE\xEF\x2A\x00\x00\x00", 2, 42), + (BIG_ENDIAN, b"\xbe\x00\x00\x00\x2a\xef", 1, 42), + (LITTLE_ENDIAN, b"\xbe\xef\x2a\x00\x00\x00", 2, 42), ] ) def read_long_fixture(self, request): diff --git a/tests/image/test_jpeg.py b/tests/image/test_jpeg.py index 8c28163..d863219 100644 --- a/tests/image/test_jpeg.py +++ b/tests/image/test_jpeg.py @@ -247,7 +247,7 @@ def it_can_construct_from_a_stream_and_offset(self, from_stream_fixture): ) def from_stream_fixture(self, request, _Marker__init_): marker_code, offset, length = request.param - bytes_ = b"\xFF\xD8\xFF\xE0\x00\x10" + bytes_ = b"\xff\xd8\xff\xe0\x00\x10" stream_reader = StreamReader(io.BytesIO(bytes_), BIG_ENDIAN) return stream_reader, marker_code, offset, _Marker__init_, length @@ -258,7 +258,7 @@ def _Marker__init_(self, request): class Describe_App0Marker: def it_can_construct_from_a_stream_and_offset(self, _App0Marker__init_): - bytes_ = b"\x00\x10JFIF\x00\x01\x01\x01\x00\x2A\x00\x18" + bytes_ = b"\x00\x10JFIF\x00\x01\x01\x01\x00\x2a\x00\x18" marker_code, offset, length = JPEG_MARKER_CODE.APP0, 0, 16 density_units, x_density, y_density = 1, 42, 24 stream = StreamReader(io.BytesIO(bytes_), BIG_ENDIAN) @@ -388,7 +388,7 @@ def _tiff_from_exif_segment_(self, request, tiff_): class Describe_SofMarker: def it_can_construct_from_a_stream_and_offset(self, request, _SofMarker__init_): - bytes_ = b"\x00\x11\x00\x00\x2A\x00\x18" + bytes_ = b"\x00\x11\x00\x00\x2a\x00\x18" marker_code, offset, length = JPEG_MARKER_CODE.SOF0, 0, 17 px_width, px_height = 24, 42 stream = StreamReader(io.BytesIO(bytes_), BIG_ENDIAN) @@ -507,7 +507,7 @@ def _MarkerFinder__init_(self, request): ) def next_fixture(self, request): start, marker_code, segment_offset = request.param - bytes_ = b"\xFF\xD8\xFF\xE0\x00\x01\xFF\x00\xFF\xFF\xFF\xD9" + bytes_ = b"\xff\xd8\xff\xe0\x00\x01\xff\x00\xff\xff\xff\xd9" stream_reader = StreamReader(io.BytesIO(bytes_), BIG_ENDIAN) marker_finder = _MarkerFinder(stream_reader) expected_code_and_offset = (marker_code, segment_offset) diff --git a/tests/image/test_png.py b/tests/image/test_png.py index a47a957..19a8145 100644 --- a/tests/image/test_png.py +++ b/tests/image/test_png.py @@ -401,7 +401,7 @@ def it_can_construct_from_a_stream_and_offset(self, from_offset_fixture): @pytest.fixture def from_offset_fixture(self): - bytes_ = b"\x00\x00\x00\x2A\x00\x00\x00\x18" + bytes_ = b"\x00\x00\x00\x2a\x00\x00\x00\x18" stream_rdr = StreamReader(io.BytesIO(bytes_), BIG_ENDIAN) offset, px_width, px_height = 0, 42, 24 return stream_rdr, offset, px_width, px_height @@ -422,7 +422,7 @@ def it_can_construct_from_a_stream_and_offset(self, from_offset_fixture): @pytest.fixture def from_offset_fixture(self): - bytes_ = b"\x00\x00\x00\x2A\x00\x00\x00\x18\x01" + bytes_ = b"\x00\x00\x00\x2a\x00\x00\x00\x18\x01" stream_rdr = StreamReader(io.BytesIO(bytes_), BIG_ENDIAN) offset, horz_px_per_unit, vert_px_per_unit, units_specifier = (0, 42, 24, 1) return (stream_rdr, offset, horz_px_per_unit, vert_px_per_unit, units_specifier) diff --git a/tests/image/test_tiff.py b/tests/image/test_tiff.py index d585d47..43f2f6a 100644 --- a/tests/image/test_tiff.py +++ b/tests/image/test_tiff.py @@ -420,7 +420,7 @@ def it_can_parse_an_ascii_string_IFD_entry(self): class Describe_ShortIfdEntry: def it_can_parse_a_short_int_IFD_entry(self): - bytes_ = b"foobaroo\x00\x2A" + bytes_ = b"foobaroo\x00\x2a" stream_rdr = StreamReader(io.BytesIO(bytes_), BIG_ENDIAN) val = _ShortIfdEntry._parse_value(stream_rdr, 0, 1, None) assert val == 42 @@ -428,7 +428,7 @@ def it_can_parse_a_short_int_IFD_entry(self): class Describe_LongIfdEntry: def it_can_parse_a_long_int_IFD_entry(self): - bytes_ = b"foobaroo\x00\x00\x00\x2A" + bytes_ = b"foobaroo\x00\x00\x00\x2a" stream_rdr = StreamReader(io.BytesIO(bytes_), BIG_ENDIAN) val = _LongIfdEntry._parse_value(stream_rdr, 0, 1, None) assert val == 42 @@ -436,7 +436,7 @@ def it_can_parse_a_long_int_IFD_entry(self): class Describe_RationalIfdEntry: def it_can_parse_a_rational_IFD_entry(self): - bytes_ = b"\x00\x00\x00\x2A\x00\x00\x00\x54" + bytes_ = b"\x00\x00\x00\x2a\x00\x00\x00\x54" stream_rdr = StreamReader(io.BytesIO(bytes_), BIG_ENDIAN) val = _RationalIfdEntry._parse_value(stream_rdr, None, 1, 0) assert val == 0.5 From 4450382135019ec490dcadfb261f2f6b70a65350 Mon Sep 17 00:00:00 2001 From: skelmis Date: Sun, 15 Jun 2025 15:38:21 +1200 Subject: [PATCH 13/13] Bump deps and bring project inline with new black and ruff spec --- pyproject.toml | 2 +- src/skelmis/docx/text/paragraph.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 603a5e1..8ad0c79 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -110,7 +110,7 @@ python_functions = ["it_", "its_", "they_", "and_", "but_"] [tool.ruff] exclude = [] -line-length = 125 +line-length = 100 target-version = "py310" [tool.ruff.lint] diff --git a/src/skelmis/docx/text/paragraph.py b/src/skelmis/docx/text/paragraph.py index 0e12aad..17d1755 100644 --- a/src/skelmis/docx/text/paragraph.py +++ b/src/skelmis/docx/text/paragraph.py @@ -60,11 +60,13 @@ def insert_table_of_contents( outside of this range. Format is -, i.e. 2-5 to only show page numbers for first level headings. ``show_page_numbers`` must be ``True`` for this setting to work. - :param fill_space_with: How to fill the remaining space on a line. Referred to technically as the tab stops. - :param hide_tab_leader_and_page_numbers_in_web_layout_view: Hides tab leader and page numbers in Web layout view. + :param fill_space_with: How to fill the remaining space on a line. Referred to + technically as the tab stops. + :param hide_tab_leader_and_page_numbers_in_web_layout_view: Hides tab leader + and page numbers in Web layout view. :param styles: The paragraph styles to use instead of the built-in ones. - Format is list[tuple[int(HeadingLevel), str(StyleName)]]. N.b this field follows the spec, - but is not tested for correctness currently. + Format is list[tuple[int(HeadingLevel), str(StyleName)]]. N.b this field follows + the spec, but is not tested for correctness currently. Derived from the following comment: https://github.com/python-openxml/python-docx/issues/36#issuecomment-2739396561