generated from WSH032/pyproject-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyproject.toml
293 lines (252 loc) · 8.67 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
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
286
287
288
289
290
291
292
293
# https://hatch.pypa.io/latest/config/metadata/
[project]
name = "aria2-server"
requires-python = ">=3.8"
readme = "README.md"
license = { file = "LICENSE" }
authors = [
{ name = "Sean Wang", email = "126865849+WSH032@users.noreply.github.com" },
]
description = "aria2 server with gui, python/desktop/remote downloader" # EDIT
keywords = [
"aria2",
"downloader",
"gui",
"server",
"python",
"desktop",
"remote",
] # EDIT
# 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",
] # EDIT
dynamic = ["version"]
# NOTE: version constraints
# https://iscinumpy.dev/post/bound-version-constraints/
dependencies = [
"pydantic == 2.*",
"fastapi >= 0.108, < 1",
"nicegui >= 1.4.8, < 2",
"uvicorn[standard] >= 0.22, < 1",
"typing_extensions >= 4.6, < 5",
"fastapi-proxy-lib >= 0.1.0, < 1",
"httpx >= 0.26.0, < 1",
# db
"sqlalchemy == 2.*",
"alembic >= 1.13, < 2",
# auth
"fastapi-users[sqlalchemy] >= 12.1, < 13",
"aiosqlite >=0.19, < 1",
# config
"tomli == 2.*",
# ssl
# NOTE: DO NOT limit `cryptography` major version,
# see https://cryptography.io/en/latest/api-stability/
"cryptography",
# cli
"typer >= 0.9, < 1",
]
[project.optional-dependencies]
dev = ["Babel==2.14.0"]
# NOTE: Must use `==` to constrain version for github actions cache working properly
dev_fmt = [
"ruff==0.2.0",
"codespell==2.2.6",
"tomli", # tomli needed for `codespell`
]
# NOTE: Must use `==` to constrain version for github actions cache working properly
dev_test = [
"pyright == 1.1.349",
"pytest==7.4.4",
"pytest-cov== 4.1.0",
"pytest-timeout==2.2.0",
]
# NOTE: Must use `==` to constrain version for github actions cache working properly
dev_docs = [
"mkdocs-material == 9.5.3",
"mkdocstrings[python] == 0.24.0",
# We need black to format code in mkdocstrings,
# see https://mkdocstrings.github.io/python/usage/configuration/signatures/#line_length
"black == 24.1.1",
"mkdocs-gen-files == 0.5.0",
"mkdocs-literate-nav == 0.6.1",
"mkdocs-section-index == 0.3.8",
"mkdocs-git-revision-date-localized-plugin == 1.2.2",
"mkdocs-git-committers-plugin-2 == 2.2.2",
"griffe-inherited-docstrings == 1.0.0",
]
[project.urls]
Documentation = "https://WSH032.github.io/aria2-server-gui/"
"Source code" = "https://github.com/WSH032/aria2-server-gui/"
# https://hatch.pypa.io/latest/config/metadata/#cli
[project.scripts]
aria2-server = "aria2_server.cli:cli"
[build-system]
requires = ["hatch-regex-commit"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
# https://hatch.pypa.io/latest/plugins/builder/wheel/#default-file-selection
# https://hatch.pypa.io/latest/config/build/#packages
sources = ["src"]
[tool.hatch.version]
# refer to: https://github.com/frankie567/hatch-regex-commit
source = "regex_commit"
commit_extra_args = ["-e"]
path = "src/aria2_server/__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-default" # NOTE: Do not change the path, it's used in github action cache
features = ["dev", "dev_test"]
# NOTE: Do not change the scripts name, it's used in pre-commit local hook
[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"
type-check = [
"pyright .",
# FIXME, TODO: when we release v1.0, we will enable pyright verifytypes check
# "pyright --verifytypes aria2_server --ignoreexternal",
]
[tool.hatch.envs.fmt]
path = ".venv-fmt" # NOTE: Do not change the path, it's used in github action cache
features = ["dev_fmt"]
detached = true
# NOTE: Do not change the scripts name, it's used in pre-commit local hook
[tool.hatch.envs.fmt.scripts]
# lint must before format
fmt = ["- ruff check . --fix", "- ruff format ."]
spell-fix = "codespell . -i 3 -w"
fmt-check = ["ruff check .", "ruff format --check .", "codespell ."]
[tool.hatch.envs.docs]
path = ".venv-docs" # NOTE: Do not change the path, it's used in github action cache
features = ["dev_docs"]
detached = true
# NOTE: Do not change the scripts name, it's used in pre-commit local hook
[tool.hatch.envs.docs.scripts]
serve = "mkdocs serve"
build = "mkdocs build"
[tool.ruff.format]
docstring-code-format = true
# https://docs.astral.sh/ruff/rules/
[tool.ruff.lint]
preview = true
explicit-preview-rules = true
# we use `extend-select` to enable preview rules
extend-select = ["RUF022"] # unsorted-dunder-all
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
"ISC001",
# "D418", # Function decorated with `@overload` shouldn't contain a docstring
# "SIM108", # if-else-block-instead-of-if-exp
"B008", # function-call-in-default-argument; conflicts with fastapi depends injection
# FIXME, TODO: when we release v0.1, we will add docstring
"D",
]
[tool.ruff.lint.per-file-ignores]
"src/aria2_server/db/migrations/alembic/*" = ["D"]
"src/*" = ["PT018"]
# https://docs.astral.sh/ruff/settings/#pydocstyle
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.isort]
known-first-party = ["aria2_server"]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"
# https://microsoft.github.io/pyright/#/configuration
[tool.pyright]
typeCheckingMode = "strict"
pythonVersion = "3.8"
pythonPlatform = "All"
# rules
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 = ['aria2_server']
# 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,./src/aria2_server/static/AriaNg"
[tool.pytest.ini_options]
timeout = 15