/
pyproject.toml
222 lines (194 loc) · 8.17 KB
/
pyproject.toml
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
# See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#writing-pyproject-toml
[tool.poetry]
name = "dsp-tools"
version = "7.2.0"
description = "DSP-TOOLS is a Python package with a command line interface that helps you interact with a DaSCH service platform (DSP) server."
authors = ["DaSCH - Swiss National Data and Service Center for the Humanities <info@dasch.swiss>"]
readme = "docs/index.md"
license = "GPL-3.0-only"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: OS Independent",
]
documentation = "https://docs.dasch.swiss/latest/DSP-TOOLS/"
homepage = "https://www.dasch.swiss/"
repository = "https://github.com/dasch-swiss/dsp-tools"
include = [
"src/dsp_tools/resources/*",
"src/dsp_tools/py.typed" # see https://mypy.readthedocs.io/en/stable/installed_packages.html#making-pep-561-compatible-packages
]
[tool.poetry.dependencies]
python = "^3.12"
jsonpath-ng = "^1.6.1"
argparse = "^1.4.0"
lxml = "^5.2.1"
requests = "^2.31.0"
jsonschema = "^4.21.1"
openpyxl = "^3.1.2"
networkx = "^3.3"
pandas = {version = "^2.2.1", extras = ["excel"]} # extra package that contains xlrd that is necessary for reading old .xls Excel files
regex = "^2024.4.28"
pyyaml = "^6.0.1"
rustworkx = "^0.14.2"
termcolor = "^2.4.0"
packaging = "^24.0"
loguru = "^0.7.2"
[tool.poetry.group.dev.dependencies]
mkdocs = "^1.5.3"
mkdocs-material = "^9.5.17"
mkdocs-include-markdown-plugin = "^6.0.5"
mypy = "^1.10.0"
pytest = "^8.1.1"
pre-commit = "^3.7.0"
darglint = "^1.8.1"
types-requests = "^2.31.0.20240403"
types-lxml = "^2024.3.27"
types-jsonschema = "^4.21.0.20240331"
types-openpyxl = "^3.1.0.20240402"
types-regex = "^2024.4.28.20240430"
types-pyyaml = "^6.0.12.20240311"
pytest-unordered = "^0.6.0"
viztracer = "^0.16.2"
ruff = "^0.4.2"
pytest-sugar = "^1.0.0"
pandas-stubs = "^2.2.1.240316"
types-networkx = "^3.2.1.20240331"
[tool.poetry.scripts]
dsp-tools = "dsp_tools.cli.entry_point:main" # definition of the CLI entry point
[tool.poetry-exec-plugin.commands]
# plugin (https://github.com/keattang/poetry-exec-plugin) to define commands available for the developers,
# e.g. `poetry exec check-links`
check-links = """
markdown-link-validator ./docs \
-i \\.\\/assets\\/.+ \
-i .+github\\.com\\/dasch\\-swiss\\/dsp-tools\\/settings \
-i .+github\\.com\\/dasch\\-swiss\\/ops-deploy\\/.+\
"""
darglint = """
find . -name "*.py" \
-not -path "./src/dsp_tools/commands/project/models/*" \
-not -path "./.git/*" \
-not -path "./.venv/*" \
| xargs poetry run darglint -v 2\
"""
clean = """
rm -rf **/*.pyc
rm -rf **/__pycache__
rm -rf **/.pytest_cache
rm -rf **/.mypy_cache
rm -rf *id2iri_mapping*.json
"""
markdownlint = """
docker run \
-v $PWD:/workdir ghcr.io/igorshubovych/markdownlint-cli:latest \
--config .markdownlint.yml \
--ignore CHANGELOG.md "**/*.md"
"""
ruff-check = "ruff check . --ignore=A002,D101,D102,PLR0913,PLR2004,PLW0603"
ruff-check-github = """
ruff check . --output-format=github --ignore=A002,D101,D102,PLR0913,PLR2004,PLW0603
"""
ruff-format-check = "ruff format --check ."
mypy = "mypy ."
unittests = "pytest test/unittests/"
integration-tests = "pytest test/integration/"
e2e-tests = "pytest test/e2e/"
bump-version = """
# get current version, append ".postN" (N=no. of commits since last release), write back into pyproject.toml
version=$(git describe --tags --abbrev=0)
commit_cnt=$(git rev-list --count main ^$version)
commit_cnt=$((commit_cnt - 1)) # N in ".postN" is zero-based
if [ $commit_cnt -eq -1 ]; then exit 0; fi
new_version=$(poetry version -s).post$commit_cnt # pyproject.toml contains clean numbers, .postN isn't commited
poetry version $new_version # write back into pyproject.toml
"""
[build-system]
# Tells “frontend” build tools (like pip, build, or poetry) what “backend” build tool to use (e.g. setuptools, poetry).
# The "backend" doesn't need to be installed. It will be installed by the "frontend" in a temporary, isolated
# environment for use during the build process.
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.pytest.ini_options]
addopts = ["--import-mode=importlib"]
# see https://docs.pytest.org/en/latest/explanation/goodpractices.html#tests-outside-application-code
pythonpath = [".", "src", "test"]
[tool.mypy]
show_column_numbers = true
strict = true
exclude = [
"src/dsp_tools/models/datetimestamp.py", # TODO: activate this
"src/dsp_tools/models/langstring.py", # TODO: activate this
"src/dsp_tools/models/projectContext.py", # TODO: activate this
"src/dsp_tools/commands/project/models/context.py", # TODO: activate this
"src/dsp_tools/commands/project/models/group.py", # TODO: activate this
"src/dsp_tools/commands/project/models/helpers.py", # TODO: activate this
"src/dsp_tools/commands/project/models/listnode.py", # TODO: activate this
"src/dsp_tools/commands/project/models/ontology.py", # TODO: activate this
"src/dsp_tools/commands/project/models/project.py", # TODO: activate this
"src/dsp_tools/commands/project/models/propertyclass.py", # TODO: activate this
"src/dsp_tools/commands/project/models/resourceclass.py", # TODO: activate this
"src/dsp_tools/commands/project/models/user.py", # TODO: activate this
]
[[tool.mypy.overrides]]
module = ["jsonpath_ng.*", "viztracer.*"] # For these packages, no type stubs are available yet
ignore_missing_imports = true
[tool.ruff]
line-length = 120
target-version = "py312"
[tool.ruff.lint]
select = [
"RUF", # ruff-specific rules
"PL", # pylint
"I", # isort
"E", # pycodestyle errors
"F", # pyflakes
"A", # flake8-builtins
"BLE", # flake8-blind-except
"ARG", # flake8-unused-arguments
"S", # flake8-bandit plugin which checks for security issues
"YTT", # flake8-2020 plugin, which checks for misuse of `sys.version` or `sys.version_info`
"ASYNC", # flake8-async plugin, which checks for bad async / asyncio practices
"ISC", # flake8-implicit-str-concat plugin, which checks for problematic string concatenation
"INP", # flake8-no-pep420 plugin, which checks for missing __init__.py files
"PIE", # flake8-pie plugin, which does miscellaneous checks
"PT", # flake8-pytest-style plugin
"TID", # flake8-tidy-imports plugin
"ICN", # flake8-import-conventions plugin, which checks for import conventions
"ARG", # flake8-unused-arguments
"PGH", # pygrep-hooks: A collection of fast, cheap, regex based pre-commit hooks
"UP031", # pyupgrade: printf-string-formatting
"D101", # pydocstyle: undocumented-public-class
"D102", # pydocstyle: undocumented-public-method
"D103", # pydocstyle: undocumented-public-function
"D417", # pydocstyle: undocumented-param
"B023", # flake8-bugbear: function-uses-loop-variable
"FIX", # flake8-fixme: checks for FIXME, TODO, XXX, etc.
]
ignore = [
"ISC001", # flake8-implicit-str-concat: single-line-implicit-string-concatenation # incompatible with the formatter
"S105", # flake8-bandit: hardcoded password
"S106", # flake8-bandit: hardcoded password
"S603", # flake8-bandit: subprocess-without-shell-equals-true
"S320", # flake8-bandit: xml parsing vulnerable to XML attacks
]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = [
"F401", # unused-import
"F403", # undefined-local-with-import-star
"PLC0414", # useless-import-alias
]
"testdata/**" = [
"INP001", # implicit-namespace-package # there are some python files, but no __init__.py
]
"test/*" = [
"D103", # pydocstyle: undocumented-public-function
"D102", # pydocstyle: undocumented-public-method
"D101", # pydocstyle: undocumented-public-class
"S101", # flake8-bandit: use of assert
]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.isort]
force-single-line = true
known-first-party = ["dsp_tools"]