Skip to content
Closed

Dev #94

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pypi-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 10 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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"
Expand All @@ -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
4 changes: 2 additions & 2 deletions docx2python/attribute_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion docx2python/bullets_and_numbering.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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"]
Expand All @@ -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
Expand Down
48 changes: 16 additions & 32 deletions tests/test_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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
Expand All @@ -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(
Expand Down
30 changes: 10 additions & 20 deletions tests/test_docx2python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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----",
]
],
Expand All @@ -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----",
]
],
Expand Down Expand Up @@ -202,10 +196,8 @@ def test_formatting_captured(self) -> None:
'<span style="color:FF0000">Colored</span>',
'<span style="color:FF0000;font-size:40pt">Large Colored</span>',
'<span style="font-size:40pt"><b>Large Bold</b></span>',
par(
"""<span style="font-size:40pt"><b><i><u>Large Bold Italics
Underlined</u></i></b></span>"""
),
par("""<span style="font-size:40pt"><b><i><u>Large Bold Italics
Underlined</u></i></b></span>"""),
]

def test_paragraph_formatting(self) -> None:
Expand All @@ -223,10 +215,8 @@ def test_paragraph_formatting(self) -> None:
["<h2>", "Heading 2", "</h2>"],
[],
[
par(
"""----Image alt text---->A jellyfish in
water\n\nDescription automatically generated<"""
),
par("""----Image alt text---->A jellyfish in
water\n\nDescription automatically generated<"""),
"----media/image2.jpg----",
],
]
Expand Down
22 changes: 6 additions & 16 deletions tests/test_more_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,21 @@ def test_paragraphs_only() -> None:
expect = [
(
"",
[
par(
"""[Grab your reader’s attention with a great quote from the
[par("""[Grab your reader’s attention with a great quote from the
document or use this space to emphasize a key point. To place
this text box anywhere on the page, just drag it.]"""
)
],
this text box anywhere on the page, just drag it.]""")],
),
(
"",
[
par(
"""[Grab your reader’s attention with a great quote from the
[par("""[Grab your reader’s attention with a great quote from the
document or use this space to emphasize a key point. To place
this text box anywhere on the page, just drag it.]"""
)
],
this text box anywhere on the page, just drag it.]""")],
),
(
"Heading1",
[
"<h1>",
par(
"""aaa aab aac aad aae aaf aag aah aai aaj aak aal aam aan aao
par("""aaa aab aac aad aae aaf aag aah aai aaj aak aal aam aan aao
aap aaq aar aas aat aau aav aaw aax aay aaz aba abb abc abd abe
abf abg abh abi abj abk abl abm abn abo abp abq abr abs abt abu
abv abw abx aby abz aca acb acc acd ace acf acg ach aci acj ack
Expand Down Expand Up @@ -158,8 +149,7 @@ def test_paragraphs_only() -> None:
axz aya ayb ayc ayd aye ayf ayg ayh ayi ayj ayk ayl aym ayn ayo
ayp ayq ayr ays ayt ayu ayv ayw ayx ayy ayz aza azb azc azd aze
azf azg azh azi azj azk azl azm azn azo azp azq azr azs azt azu
azv azw azx azy azz"""
),
azv azw azx azy azz"""),
"</h1>",
],
),
Expand Down
Loading