-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyproject.toml
More file actions
231 lines (214 loc) · 6.72 KB
/
pyproject.toml
File metadata and controls
231 lines (214 loc) · 6.72 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
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
# TEMPLATE: After forking, replace the placeholders below.
# See TEMPLATE.md for the full instantiation checklist.
[project]
name = "REPLACE_ME-project-name"
version = "0.1.0"
license = {text = "Apache-2.0"}
authors = [
{name = "REPLACE_ME Author", email = "replace-me@example.com"},
]
description = "REPLACE_ME — short project description"
readme = "README.md"
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
]
[project.optional-dependencies]
dev = [
# Linting & Formatting (Ruff replaces black, flake8, isort, pylint, pyupgrade)
"ruff>=0.8.0",
# Type checking
"mypy>=1.16.1",
# Security
"bandit[toml]>=1.8.0",
# Testing
"pytest>=9.0.3",
"pytest-cov>=6.2.0",
"pytest-xdist>=3.5.0", # Parallel test execution
"pytest-randomly>=3.16.0", # Randomize test order
"pytest-timeout>=2.3.0", # Test timeouts
"hypothesis>=6.120.0", # Property-based testing
# Development tools
"pre-commit>=4.2.0",
"pip-audit>=2.7.0", # Dependency vulnerability scanning
]
[tool.pytest.ini_options]
minversion = "8.4"
addopts = "-ra -q --strict-markers --strict-config"
testpaths = ["tests"]
python_files = ["test_*.py", "*_test.py"]
python_functions = ["test_*"]
python_classes = ["Test*"]
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"integration: marks tests as integration tests",
"unit: marks tests as unit tests",
]
filterwarnings = [
"error",
"ignore::DeprecationWarning",
"ignore::PendingDeprecationWarning",
]
xfail_strict = true
[tool.coverage.run]
source = ["src"]
omit = ["*/tests/*", "*/test_*.py"]
[tool.coverage.report]
fail_under = 100
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]
[tool.mypy]
python_version = "3.11"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
warn_unreachable = true
strict_equality = true
strict = true
show_error_codes = true
show_column_numbers = true
pretty = true
[[tool.mypy.overrides]]
module = "tests.*"
disallow_untyped_decorators = false
# ===========================
# Ruff Configuration
# ===========================
[tool.ruff]
target-version = "py311"
line-length = 120
src = ["src", "tests"]
[tool.ruff.lint]
select = [
"F", # Pyflakes
"E", # pycodestyle errors
"W", # pycodestyle warnings
"C90", # mccabe complexity
"I", # isort
"N", # pep8-naming
"D", # pydocstyle
"UP", # pyupgrade
"YTT", # flake8-2020
"ANN", # flake8-annotations
"ASYNC", # flake8-async
"S", # flake8-bandit (security)
"BLE", # flake8-blind-except
"FBT", # flake8-boolean-trap
"B", # flake8-bugbear
"A", # flake8-builtins
"COM", # flake8-commas
"C4", # flake8-comprehensions
"DTZ", # flake8-datetimez
"T10", # flake8-debugger
"EM", # flake8-errmsg
"EXE", # flake8-executable
"FA", # flake8-future-annotations
"ISC", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
"LOG", # flake8-logging
"G", # flake8-logging-format
"INP", # flake8-no-pep420
"PIE", # flake8-pie
"T20", # flake8-print
"PYI", # flake8-pyi
"PT", # flake8-pytest-style
"Q", # flake8-quotes
"RSE", # flake8-raise
"RET", # flake8-return
"SLF", # flake8-self
"SLOT", # flake8-slots
"SIM", # flake8-simplify
"TID", # flake8-tidy-imports
"TCH", # flake8-type-checking
"INT", # flake8-gettext
"ARG", # flake8-unused-arguments
"PTH", # flake8-use-pathlib
"TD", # flake8-todos
"FIX", # flake8-fixme
"ERA", # eradicate (commented-out code)
"PD", # pandas-vet
"PGH", # pygrep-hooks
"PL", # Pylint
"TRY", # tryceratops
"FLY", # flynt
"NPY", # NumPy-specific rules
"PERF", # Perflint
"FURB", # refurb
"RUF", # Ruff-specific rules
]
ignore = [
"D100", # Missing docstring in public module (handled at package level)
"D104", # Missing docstring in public package
"D203", # 1 blank line required before class docstring (conflicts with D211)
"D213", # Multi-line docstring summary should start at the second line (conflicts with D212)
"COM812", # Trailing comma missing (conflicts with formatter)
"ISC001", # Single line implicit string concatenation (conflicts with formatter)
"TD003", # Missing issue link on TODO
"FIX002", # Line contains TODO
]
[tool.ruff.lint.per-file-ignores]
"tests/**/*.py" = [
"S101", # Use of assert detected (expected in tests)
"ARG", # Unused function args (fixtures may be unused directly)
"FBT", # Boolean trap (acceptable in tests)
"PLR2004", # Magic value used in comparison
"D103", # Missing docstring in public function (test methods)
"ANN", # Missing type annotations (tests don't need full annotations)
"S311", # Standard pseudo-random generators (ok in tests)
"PLC0415", # Import should be at top-level (needed for testing imports)
"TRY003", # Long messages in exceptions (ok in tests)
"EM101", # String literal in exception (ok in tests)
"PT006", # Wrong type for parametrize (string is fine)
"PT012", # pytest.raises block (complex blocks ok in tests)
]
"src/**/conftest.py" = ["INP001"]
"tests/conftest.py" = ["INP001", "PLC0415"]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.mccabe]
max-complexity = 10
[tool.ruff.lint.isort]
# TEMPLATE: replace "hello_world" with the actual package name (matches src/<package>/).
known-first-party = ["hello_world"]
force-single-line = false
lines-after-imports = 2
[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"
inline-quotes = "double"
[tool.ruff.lint.pylint]
max-args = 5
max-branches = 12
max-returns = 6
max-statements = 50
# ===========================
# Bandit Configuration
# ===========================
[tool.bandit]
targets = ["src"]
exclude_dirs = ["tests", ".venv", "venv"]
skips = ["B101"] # Skip assert warnings (we use them appropriately)
[tool.bandit.assert_used]
skips = ["**/test_*.py", "**/tests/**"]