-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyproject.toml
242 lines (210 loc) Β· 7.33 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# https://hatch.pypa.io/latest/config/metadata/
[project]
name = "aria2" # not `aria2c`, to keep style with `apt install aria2`
requires-python = ">=3.8"
readme = "README.md"
license = { file = "LICENSE" }
authors = [
{ name = "Sean Wang", email = "[email protected]" },
]
description = "python wheel for aria2 static build."
keywords = ["aria2", "aria2c", "aria2c.exe", "aria2-static"]
# https://pypi.org/classifiers/
classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
]
dynamic = ["version"]
# NOTE: version constraints
# https://iscinumpy.dev/post/bound-version-constraints/
dependencies = []
[project.urls]
Documentation = "https://WSH032.github.io/aria2-wheel/"
"Source code" = "https://github.com/WSH032/aria2-wheel/"
# https://hatch.pypa.io/latest/config/metadata/#cli
[project.scripts]
aria2c = "aria2c:main"
[build-system]
requires = [
"hatch-regex-commit",
# keep following build dependencies versions sync with `[tool.hatch.envs.default]`
"hatchling >= 1.13.0",
"httpx",
"packaging",
"typing-extensions >= 4.5",
]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
# artifacts = ["src/aria2c/bin/*"] # we set it in `hatch_build.py` instead
# NOTE: explicitly setting `packages` is necessary, because project name is `aria2`, but package name is `aria2c`
# https://hatch.pypa.io/latest/plugins/builder/wheel/#default-file-selection
# https://hatch.pypa.io/latest/config/build/#packages
packages = ["src/aria2c"]
[tool.hatch.build.targets.wheel.hooks.custom]
path = "hatch_build.py"
[tool.hatch.version]
# refer to: https://github.com/frankie567/hatch-regex-commit
source = "regex_commit"
commit_extra_args = ["-e"]
path = "src/aria2c/__init__.py"
# NOTE: `chore` is required by commitlint
commit_message = "chore(version): π bump version v{current_version} β v{new_version}"
tag_message = "π bump version v{current_version} β v{new_version}"
# NOTE: `v` prefix is required by github `publish.yml` action
tag_name = "v{new_version}"
check_dirty = false
[tool.hatch.envs.default]
path = ".venv" # for vscode auto selecting python interpreter
dependencies = [
# NOTE: π
# The versions of `black`, `ruff`, `codespell`, must be consistent with the `.pre-commit-config.yaml`.
# Don't edit them manually, use `pre-commit run ver_sync` instead.
"black==23.11.0",
"ruff==0.1.7",
"codespell==2.2.6",
# Don't write comments on these lines, because they will be removed by `pre-commit run ver_sync`.
# NOTE: π
# lint-check
"pyright == 1.1.338", # pyright must be installed in the runtime environment
# test
"pytest == 7.*",
"pytest-cov == 4.*",
"pytest-timeout==2.*",
# build
# keep build dependencies versions sync with `build-system`
"hatchling >= 1.13.0",
"httpx",
"packaging",
"typing-extensions >= 4.5",
]
[tool.hatch.envs.default.scripts]
# https://pytest-cov.readthedocs.io/en/latest/config.html
# xml for codecov, html for local review
test = "pytest tests/ --cov --cov-report=xml --cov-report=html"
# ruff must before black
lint = ["- ruff --fix .", "- black .", "- pyright .", "- codespell . -i 3 -w"]
lint-check = [
"ruff .",
"black --check .",
"pyright .",
"pyright --verifytypes aria2c --ignoreexternal",
"codespell .",
]
check-all = ["lint-check", "test"]
# https://hatch.pypa.io/latest/config/environment/overview/#detached-environments
[tool.hatch.envs.docs]
path = ".venv-docs"
detached = true
dependencies = [
"mkdocs-material == 9.*",
"mkdocstrings[python] == 0.24.*",
"mkdocs-gen-files == 0.5.*",
"mkdocs-literate-nav == 0.6.*",
"mkdocs-section-index == 0.3.*",
"mkdocs-git-revision-date-localized-plugin == 1.*",
"mkdocs-git-committers-plugin-2 == 2.*",
]
[tool.hatch.envs.docs.scripts]
docs-serve = "mkdocs serve"
docs-build = "mkdocs build"
# https://docs.astral.sh/ruff/rules/
[tool.ruff]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"C4", # flake8-comprehensions
"B", # flake8-bugbear
"N", # pep8-naming
"UP", # pyupgrade
"D", # pydocstyle
"SIM", # flake8-simplify
"RUF", # unused-noqa
"Q", # flake8-quotes
"C90", # McCabe complexity
"ANN001", # missing-type-function-argument
"ANN201", # missing-return-type-undocumented-public-function
"ASYNC", # flake8-async
"A", # flake8-builtins
"COM", # flake8-commas
"ISC", # flake8-implicit-str-concat
"ICN001", # unconventional-import-alias
"PIE", # flake8-pie
"PT", # flake8-pytest-style
"INT", # flake8-gettext
"ARG", # flake8-unused-arguments
"PGH004", # blanket-noqa
"TRY201", # Use raise without specifying exception name
"NPY", # NumPy-specific rules
"PD", # pandas-vet
"PERF", # Perflint
"PL", # Pylint
"TID252", # Relative imports from parent modules are banned
]
ignore = [
"E501", # line too long, handled by black
"COM812", # missing-trailing-comma
"PERF203", # try-except within a loop incurs performance overhead
"PLR2004", # magic-value-comparison
"PLR5501", # collapsible-else-if
"PLW0120", # useless-else-on-loop
"PLR0911", # too-many-return-statements
"PLR0913", # too-many-arguments
"PLC0205", # single-string-slots
"PLW0603", # global-statement
"PLC1901", # compare-to-empty-string
"PLR0904", # too-many-public-methods
"RUF002", # ambiguous-unicode-character-docstring
"RUF003", # ambiguous-unicode-character-comment
"SIM105", # suppressible-exception # slower
# "D418", # Function decorated with `@overload` shouldn't contain a docstring
# "SIM108", # if-else-block-instead-of-if-exp
]
# https://docs.astral.sh/ruff/settings/#pydocstyle
[tool.ruff.pydocstyle]
convention = "google"
# [tool.ruff.flake8-tidy-imports]
# ban-relative-imports = "all"
# https://microsoft.github.io/pyright/#/configuration
[tool.pyright]
typeCheckingMode = "strict"
pythonVersion = "3.8"
reportUnusedImport = "warning"
reportUnusedFunction = "warning"
reportUnusedExpression = "warning"
reportUnusedVariable = "warning"
reportUnnecessaryTypeIgnoreComment = true
reportPrivateUsage = "warning"
reportUnnecessaryIsInstance = "warning"
reportIncompatibleMethodOverride = "warning"
reportMissingTypeArgument = true
reportMissingParameterType = true
# https://coverage.readthedocs.io/en/7.3.2/config.html#run
[tool.coverage.run]
branch = true
source = ['aria2c']
# https://coverage.readthedocs.io/en/7.3.2/config.html#report
[tool.coverage.report]
exclude_also = [
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"raise NotImplementedError",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
# # deprecated code will not be tested
"@(typing_extensions\\.)?deprecated",
# `overload` just for type hint, will not be tested
"@(typing_extensions\\.)?overload",
"@(typing\\.)?overload",
"raise AssertionError",
]
[tool.codespell]
# https://github.com/codespell-project/codespell/issues/1887
skip = "./htmlcov,./site"
[tool.pytest.ini_options]
timeout = 15