-
Notifications
You must be signed in to change notification settings - Fork 548
Expand file tree
/
Copy pathpyproject.toml
More file actions
285 lines (259 loc) · 8.77 KB
/
Copy pathpyproject.toml
File metadata and controls
285 lines (259 loc) · 8.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
[build-system]
# mypyc compilation (setup.py, gated by INVOICE2DATA_COMPILE_MYPYC) needs
# setuptools + mypy at build time. mypyc must see the types of every dependency
# used by the compiled modules, so list them here too. (dateparser is NOT here
# because `_dates.py` -- the only module that imports it -- is intentionally
# not compiled; keeping dateparser truly optional at install time.)
requires = [
"setuptools>=64",
"mypy>=1.13",
"click>=8.0.1",
"PyYAML>=6.0",
"regex>=2024.4.16",
]
build-backend = "setuptools.build_meta"
[project]
name = "invoice2data"
authors = [{ name = "Manuel Riel" }]
description = "Python parser to extract data from pdf invoice"
version = "1.0.0"
keywords = ["python", "data-mining", "accounting", "invoice", "pdf", "parcing"]
license = { text = "MIT" }
readme = "README.md"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Office/Business :: Financial",
"Topic :: Office/Business :: Financial :: Accounting",
"Environment :: Console",
"Intended Audience :: Financial and Insurance Industry",
"Intended Audience :: Developers",
"Topic :: Office/Business :: Financial :: Accounting",
"Topic :: Office/Business :: Financial",
"Topic :: Software Development :: Libraries :: Python Modules",
"Development Status :: 5 - Production/Stable",
]
dependencies = [
"click >=8.0.1",
"python-dateutil >= 2.8",
"PyYAML >= 6.0",
"regex >= 2025.2.10; python_version >= '3.12'",
"regex >= 2024.4.16; python_version < '3.12'",
]
[project.urls]
homepage = "https://github.com/invoice-x/invoice2data"
repository = "https://github.com/invoice-x/invoice2data"
documentation = "https://invoice2data.readthedocs.io"
Changelog = "https://github.com/invoice-x/invoice2data/releases"
[dependency-groups]
dev = [
"coverage[toml] >= 6.0",
"pre-commit >=2.16.0",
"pre-commit-hooks >=4.1.0",
"pytest >=8.2.2",
"pytest-mock >= 3.14.0",
"pygments >=2.10.0",
]
lint = ["ruff >=0.8", "pydoclint >=0.4.2"]
docs = [
"shibuya >= 2025.1.29",
"myst-parser >= 4.0",
"sphinx >= 8.0",
"sphinx-autobuild >= 2024.10",
"sphinx-click >= 6.0",
"sphinx-mermaid >=0.0.7",
"sphinxcontrib-svg2pdfconverter >=2.1.0",
]
mypy = ["mypy >= 1.13"]
ty = ["ty == 0.0.39"] # beta + fast-moving: pin so new diagnostics don't surprise CI
typeguard = ["typeguard >= 4.4"]
xdoctest = ["xdoctest[colors] >= 1.2"]
[project.optional-dependencies]
ai = ["httpx >= 0.27"]
camelot = ["camelot-py >= 1.0"]
dateparser = ["dateparser >= 1.2.0"]
defusedxml = ["defusedxml == 0.7.1"]
doctr = ["python-doctr[torch] >= 0.8"]
paddleocr = ["paddleocr >= 2.7", "paddlepaddle >= 2.5", "pypdfium2 >= 4"]
googlevision = [
"google-cloud-storage == 2.18.2",
"google-cloud-vision == 3.8.1",
]
hotpdf = ["hotpdf >= 0.1.0"]
ocr = ["ghostscript == 0.7"]
ocrmypdf = ["ocrmypdf >= 14.4.0"]
pdfium = ["pypdfium2 >= 4"]
pdfminer-six = ["pdfminer-six == 20231228"]
pdfoxide = ["pdf-oxide >= 0.3"]
pdfplumber = ["pdfplumber == 0.11.4"]
pyyaml = ["pyyaml == 6.0.2"]
[tool.uv]
package = true
# Published camelot-py requires pdfminer-six>=20240706, but pdfplumber==0.11.4
# and the `pdfminer-six` extra both hard-pin pdfminer.six==20231228 — a genuine
# library-level conflict (not invoice2data's pin). Mark camelot mutually
# exclusive with those pdfminer-bound extras; a camelot user runs it alongside
# the default pdfium/pdftotext cascade. (The next-major camelot drops
# pdfminer.six for playa-pdf, which will retire these once published.)
conflicts = [
[{ extra = "camelot" }, { extra = "pdfminer-six" }],
[{ extra = "camelot" }, { extra = "pdfplumber" }],
]
[tool.setuptools.packages.find]
where = ["src"]
[tool.setuptools.package-data]
# Ship py.typed + the bundled templates; test fixtures live outside src/ so
# PDFs/PNGs never enter the wheel, and setuptools omits tests/ from the sdist.
invoice2data = [
"py.typed",
"extract/templates/**/*.yml",
"extract/templates/**/*.json",
]
[project.scripts]
invoice2data = "invoice2data.__main__:main"
[tool.cibuildwheel]
# Build mypyc-compiled CPython wheels (requires-python>=3.10 is honoured
# automatically). Skip PyPy (already JIT-compiled) and musllinux.
build = "cp310-* cp311-* cp312-* cp313-*"
skip = "pp* *-musllinux*"
build-frontend = "build"
environment = { INVOICE2DATA_COMPILE_MYPYC = "1" }
# Smoke-test that the compiled extensions import on every target platform.
test-command = "python -c \"import invoice2data.extract.parsers.regex, invoice2data.extract.parsers.lines, invoice2data.extract.plugins.tables, invoice2data.extract._regex, invoice2data.extract.utils; print('mypyc import OK')\""
[tool.coverage.paths]
source = ["src", "*\\src", "*/site-packages"]
tests = ["tests", "*/tests"]
[tool.coverage.run]
branch = true
source = ["invoice2data", "tests"]
relative_files = true
[tool.coverage.report]
show_missing = true
# Locked in at 90 (combined coverage is ~94%); not the uv-forge template default
# of 100 — that's unrealistic here. Catches regressions, small buffer for variance.
fail_under = 90
exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"]
[tool.ruff.lint.isort]
force-single-line = true
lines-after-imports = 2
[tool.mypy]
strict = true
warn_unreachable = true
pretty = true
show_column_numbers = true
show_error_context = true
# Optional third-party backends/tools that ship no type information. Centralised
# here so the per-call inline imports stay clean and the result is the same
# whether or not the optional dependency happens to be installed.
[[tool.mypy.overrides]]
module = [
"pdfminer",
"pdfminer.*",
"pdfplumber",
"pypdfium2",
"pdf_oxide",
"hotpdf",
"ocrmypdf",
"defusedxml",
"defusedxml.*",
"docutils",
"docutils.*",
"sphinxmermaid",
"httpx",
"doctr",
"doctr.*",
"paddleocr",
"paddleocr.*",
"dateparser",
"dateparser.*",
"dateutil",
"dateutil.*",
]
ignore_missing_imports = true
# `google.cloud` is a namespace package: mypy partially resolves it (so
# ignore_missing_imports does not apply), but the optional storage/vision
# submodules are absent. camelot is untyped and only re-exports `read_pdf`
# implicitly (tripping strict no-implicit-reexport when it happens to be
# installed). Skip following both entirely so they are treated as Any.
[[tool.mypy.overrides]]
module = ["google", "google.*", "camelot", "camelot.*"]
follow_imports = "skip"
ignore_missing_imports = true
[tool.ty.rules]
# ty (beta, advisory) runs without the optional backend extras installed — some
# of them conflict (see [tool.uv] conflicts), so they can't all be present. mypy
# is the authoritative checker for imports (via its overrides above); let ty skip
# the optional backends it can't resolve rather than fail.
unresolved-import = "ignore"
[tool.ruff]
src = ["src", "tests"]
[tool.ruff.lint]
extend-select = [
"ASYNC", # flake8-async
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"C90", # mccabe
"D", # pydocstyle
"E", # pycodestyle
"F", # pyflakes
"FURB", # refurb
"I", # isort
"LOG", # flake8-logging
"N", # pep8-naming
"PERF", # perflint
"PIE", # flake8-pie
"PTH", # flake8-use-pathlib
"RET", # flake8-return
"RUF", # Ruff-specific rules
"S", # flake8-bandit
"SIM", # flake8-simplify
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle
]
# ignore checks that conflict with ruff formatter (https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules)
extend-ignore = [
"COM812",
"COM819",
"D107", # undocumented-public-init conflicts with DOC301
"D206",
"D300",
"E111",
"E114",
"E117",
"ISC001",
"ISC002",
"Q000",
"Q001",
"Q002",
"Q003",
"W191",
"RUF013", # activate after implement typing
"D103", # fix docstrings in public functions later
"S101", # use of assert Activate later
"S603",
"UP031", # Use fstring instead of % identifier
"E501", # fix this when updating docstrings
"TRY003", # long messages in raise (would need custom exception classes)
# "DOC106",
# "DOC107",
# "DOC111",
]
[tool.ruff.lint.per-file-ignores]
"*/test_*.py" = ["S101", "D100", "D101", "D102"]
"noxfile.py" = ["S101"]
"**/conftest.py" = ["S101"]
# Test scaffolding keeps os.path; pathlib there is churn with no runtime benefit.
"tests/**" = ["PTH"]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.pydoclint]
style = 'google'
exclude = '\.git|\.nox|tests*|noxfile.py|tables.py'
arg-type-hints-in-docstring = true