-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathpyproject.toml
More file actions
391 lines (345 loc) · 8.46 KB
/
pyproject.toml
File metadata and controls
391 lines (345 loc) · 8.46 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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
[project]
name = "inject"
dynamic = ["version"]
description = "Python dependency injection framework."
license = "Apache-2.0"
readme = "README.md"
authors = [{ name = "Ivan Korobkov", email = "ivan.korobkov@gmail.com" }]
maintainers = [{ name = "Ivan Korobkov", email = "ivan.korobkov@gmail.com" }]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries :: Python Modules",
]
requires-python = ">=3.9"
dependencies = []
[project.urls]
homepage = "https://github.com/ivankorobkov/python-inject"
source = "https://github.com/ivankorobkov/python-inject"
issues = "https://github.com/ivankorobkov/python-inject/issues"
[dependency-groups]
dev = [
"ipython",
"ruff",
"mypy",
"yamllint",
{ include-group = "tests" },
]
tests = [
"pytest",
"pytest-cov",
]
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"
[tool.hatch.build.hooks.vcs]
version-file = "src/inject/_version.py"
[tool.hatch.build.targets.wheel]
packages = ["src/inject"]
[tool.hatch.build.targets.wheel.shared-data]
[tool.hatch.version]
source = "vcs"
[tool.isort]
case_sensitive = true
include_trailing_comma = true
line_length = 120
multi_line_output = 3
profile = "black"
[tool.mypy]
check_untyped_defs = true
disallow_any_generics = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
ignore_missing_imports = true
no_implicit_optional = true
python_version = "3.11"
warn_redundant_casts = true
warn_return_any = true
warn_unused_configs = true
warn_unused_ignores = true
#strict = true # TODO(pyctrl): improve typings and enable strict mode
exclude = ["tests", ".venv"]
# TODO(pyctrl): deprecate pyright — stay with mypy
[tool.pyright]
defineConstant = { DEBUG = true }
exclude = []
executionEnvironments = []
ignore = []
include = ["src/inject", "tests"]
pythonPlatform = "Linux"
pythonVersion = "3.11"
reportMissingImports = true
reportMissingTypeStubs = false
[tool.ruff]
line-length = 88
extend-exclude = [".git", ".venv", "docs"]
[tool.ruff.lint]
preview = true
extend-select = ["ALL"]
extend-ignore = [
"D10", # missing documentation
"D203", # 1 of conflicting code-styles
"D212", # 1 of conflicting code-styles
"C408", # allow `dict()` instead of literal
"TD003", # don't require issue link
# Completely disable
"FIX",
"CPY",
# formatter conflict rules
"W191",
"E111",
"E114",
"E117",
"EM101",
"EM102",
"ERA001", # commented code
"D206",
"D300",
"DOC201",
"DOC402",
"Q000",
"Q001",
"Q002",
"Q003",
"COM812",
"COM819",
"ISC001",
"ISC002",
"N818", # Exception name should be named with an Error suffix
"TRY003",
"UP006",
"UP007",
"UP035",
"UP045",
"FA100",
]
[tool.ruff.lint.extend-per-file-ignores]
"**/tests/**/test_*.py" = [
"ANN", # annotations not required in tests
"E731", # Do not assign a `lambda` expression, use a `def`
"PLC2701", # Private name import
"PLR0913", # Too many arguments in function definition
"PLR0917", # Too many positional arguments
"PLR2004", # allow "magic" values in tests
"PLR6301", # Method could be a function, class method, or static method
"PT017", # Found assertion on exception `except` block, use `pytest.raises()` instead
"PT027", # Use `pytest.raises` instead of unittest-style `assertRaisesRegex`
"S101", # allow asserts
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
"SLF001", # allow private member access
]
"/**/tests/__init__.py" = ["PLR6301"]
[tool.ruff.lint.flake8-import-conventions.extend-aliases]
"typing" = "t"
[tool.ruff.lint.flake8-import-conventions]
banned-from = ["dataclasses", "inject", "typing"]
[tool.ruff.lint.isort]
force-single-line = true
known-first-party = ["inject"]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
#ignore = [
# "B027", # Allow non-abstract empty methods in abstract base classes
# "FBT003", # Allow boolean positional values in function calls, like `dict.get(... True)`
# # Ignore checks for possible passwords
# "S105",
# "S106",
# "S107",
# # Ignore complexity
# "C901",
# "PLR0911",
# "PLR0912",
# "PLR0913",
# "PLR0915",
# "PLC1901", # empty string comparisons
# "PLW2901", # `for` loop variable overwritten
# "SIM114", # Combine `if` branches using logical `or` operator
#]
#select = [
# "A",
# "B",
# "C",
# "DTZ",
# "E",
# "EM",
# "F",
# "FBT",
# "I",
# "ICN",
# "ISC",
# "N",
# "PLC",
# "PLE",
# "PLR",
# "PLW",
# "Q",
# "RUF",
# "S",
# "SIM",
# "T",
# "TID",
# "UP",
# "W",
# "YTT",
#]
#unfixable = [
# "F401", # Don't touch unused imports
#]
#### Pytest & Coverage ####
[tool.pytest.ini_options]
minversion = "8.4"
addopts = "-vvv -ra --strict-markers --strict-config"
testpaths = ["tests"]
#filterwarnings = ["error"] # TODO(pyctrl): handle all warnings later
# Coverage configuration
[tool.coverage.run]
branch = true
[tool.coverage.report]
include_namespace_packages = true
# Regexes for lines to exclude from consideration
omit = ["*/.venv/*", "*/.tox/*", "*/.uv-cache/*"]
exclude_also = [
# Don't complain if tests don't hit defensive assertion code:
"raise NotImplementedError",
# Don't complain if non-runnable code isn't run:
"if __name__ == .__main__.:",
# Don't complain about abstract methods, they aren't run:
"@(abc\\.)?abstractmethod",
"if TYPE_CHECKING:",
]
# Tox config
[tool.tox]
requires = ["tox>=4.23", "tox-uv>=1.13"]
runner = "uv-venv-lock-runner"
skip_missing_interpreters = true
env_list = [
"py39",
"py310",
"py311",
"py312",
"py313",
"fmt-py",
"fmt-toml",
"lint-py",
#"lint-mypy", # TODO(pyctrl): make it green & uncomment
"lint-toml",
"lint-yaml",
#"lint-git",
"coverage",
]
[tool.tox.labels]
fmt = [
"fmt-py",
"fmt-toml",
]
lint = [
"lint-py",
#"lint-mypy", # TODO(pyctrl): make it green & uncomment
"lint-toml",
"lint-yaml",
#"lint-git",
]
# default env
[tool.tox.env_run_base]
description = "Run unit tests with coverage report ({env_name})"
use_develop = true
dependency_groups = ["tests"]
commands = [["pytest", { replace = "posargs", extend = true }]]
# tox envs
[tool.tox.env.lint-py]
description = "Lint python files"
deps = ["ruff"]
skip_install = true
commands = [
[
"ruff",
"format",
"--diff",
{ replace = "posargs", default = [
"{tox_root}",
], extend = true },
],
[
"ruff",
"check",
{ replace = "posargs", default = [
"{tox_root}",
], extend = true },
],
]
[tool.tox.env.lint-mypy]
description = "Type checking"
deps = ["mypy"]
commands = [["mypy", { replace = "posargs", default = ["{tox_root}"], extend = true }]]
[tool.tox.env.lint-toml]
description = "Lint TOML files"
allowlist_externals = ["taplo"]
skip_install = true
commands = [
["taplo", "lint", { replace = "posargs", extend = true }],
["taplo", "format", "--check", "--diff", { replace = "posargs", extend = true }],
]
[tool.tox.env.lint-yaml]
description = "Lint YAML files"
deps = ["yamllint"]
skip_install = true
commands = [
[
"yamllint",
"--strict",
{ replace = "posargs", default = [
"{tox_root}",
], extend = true },
],
]
[tool.tox.env.fmt-py]
description = "Format python files"
deps = ["ruff"]
skip_install = true
commands = [
[
"ruff",
"format",
{ replace = "posargs", default = ["{tox_root}"], extend = true },
],
[
"ruff",
"check",
"--fix",
"--show-fixes",
{ replace = "posargs", default = ["{tox_root}"], extend = true },
],
]
[tool.tox.env.fmt-toml]
description = "Format TOML files"
allowlist_externals = ["taplo"]
skip_install = true
commands = [["taplo", "format", { replace = "posargs", extend = true }]]
[tool.tox.env.coverage]
description = "run coverage"
use_develop = true
dependency_groups = ["tests"]
commands = [
[
"pytest",
"--cov=.",
"--cov-branch",
"--cov-report=term-missing:skip-covered",
{ replace = "posargs", default = ["--cov-report=xml:coverage.xml"], extend = true },
],
]