Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
401 lines (387 loc) · 17.9 KB
/
Copy pathpyproject.toml
File metadata and controls
401 lines (387 loc) · 17.9 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
392
393
394
395
396
397
398
399
400
401
# Netsuke publishes a Rust crate; this file exists solely to configure the
# Python linters and typechecker that guard the repository's helper scripts
# and workflow contract tests. It deliberately declares no `[project]` table
# and no `[build-system]`, so no Python distribution can be built from it and
# `uv` never treats the repository as a Python project.
#
# The Ruff and Pylint configurations mirror the ones in
# https://github.com/leynos/episodic/blob/main/pyproject.toml so the df12
# house policy stays consistent across the estate; only the path-shaped
# settings (excludes, per-file ignores, Pylint ignore list) are local.
[tool.ruff]
line-length = 88
preview = true
# Match the Python 3.14 baseline the repository's uv-driven tooling targets,
# so lint rules and version-gated fixes resolve correctly.
target-version = "py314"
extend-exclude = [
".uv-cache",
".uv-tools",
"target",
]
[tool.ruff.lint]
select = [
"F", # Pyflakes rules
"W", # PyCodeStyle warnings
"E", # PyCodeStyle errors
"I", # Sort imports properly
"UP", # Warn if certain things can changed due to newer Python versions
"C4", # Catch incorrect use of comprehensions, dict, list, etc
"ISC", # Good use of string concatenation
"ICN", # Use common import conventions
"RET", # Good return practices
"SIM", # Common simplification rules
"TID", # Some good import practices
"TC", # Enforce importing certain types in a TYPE_CHECKING block
"PTH", # Use pathlib instead of os.path
"TD", # Be diligent with TODO comments
"A", # detect shadowed builtins
"BLE", # disallow catch-all exceptions
"S", # disallow things like "exec"; also restricts "assert" but I just NOQA it when I really need it
"DTZ", # require strict timezone manipulation with datetime
"FBT", # detect boolean traps
"N", # enforce naming conventions, e.g. ClassName vs function_name
"FURB",
"B",
"RUF",
"LOG",
"Q",
"PT",
"RSE",
"PERF",
"TRY",
"ASYNC",
"D",
"DOC",
"ANN",
"C90",
"PLR",
"modified-iterating-set",
"no-classmethod-decorator",
"no-staticmethod-decorator",
"too-many-locals",
"too-many-boolean-expressions",
"too-many-nested-blocks",
"non-augmented-assignment",
"literal-membership",
"no-self-use",
"unnecessary-lambda",
"none-not-at-end-of-union",
"class-with-mixed-type-vars",
"unnecessary-regular-expression",
"non-octal-permissions",
"property-without-return",
]
extend-ignore = [
"incorrect-blank-line-before-class", # Conflicts with D211; prefer enforcing no blank line before class docstring.
"multi-line-summary-second-line", # Conflicts with D212; keep summary on the first line.
]
[tool.ruff.lint.per-file-ignores]
# Test modules assert freely, take wide fixture surfaces, and compare against
# literal expectations; those idioms are the point of a test, not a smell.
"scripts/tests/*.py" = ["assert", "too-many-arguments", "too-many-positional-arguments", "magic-value-comparison", "no-self-use"]
"tests/workflow_contracts/*.py" = ["assert", "too-many-arguments", "too-many-positional-arguments", "magic-value-comparison", "no-self-use"]
# Cyclopts entry points declare one keyword-only parameter per environment
# input by design, so the argument-count ceilings do not apply to them.
"scripts/ci/*.py" = ["too-many-arguments", "too-many-positional-arguments"]
[tool.ruff.lint.flake8-type-checking]
# Cyclopts reads a command's annotations when it builds the command, so the
# option dataclasses a command names must stay importable at runtime rather
# than moving into a type-checking block.
runtime-evaluated-decorators = ["cyclopts.App.command"]
[tool.ruff.lint.flake8-import-conventions]
# Declare the banned `from` imports.
banned-from = [
"typing",
"datetime",
"collections.abc",
"dataclasses",
"enum",
"unittest.mock",
"msgspec",
]
[tool.ruff.lint.flake8-import-conventions.aliases]
# Declare the default aliases.
altair = "alt"
"matplotlib.pyplot" = "plt"
numpy = "np"
pandas = "pd"
seaborn = "sns"
scipy = "sp"
"collections.abc" = "cabc"
datetime = "dt"
"unittest.mock" = "mock"
"msgspec.json" = "msjson"
typing = "typ"
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"typing.AbstractSet".msg = "Use collections.abc.Set instead of deprecated typing generics."
"typing.AsyncContextManager".msg = "Use contextlib.AbstractAsyncContextManager instead of deprecated typing generics."
"typing.AsyncGenerator".msg = "Use collections.abc.AsyncGenerator instead of deprecated typing generics."
"typing.AsyncIterable".msg = "Use collections.abc.AsyncIterable instead of deprecated typing generics."
"typing.AsyncIterator".msg = "Use collections.abc.AsyncIterator instead of deprecated typing generics."
"typing.Awaitable".msg = "Use collections.abc.Awaitable instead of deprecated typing generics."
"typing.Callable".msg = "Use collections.abc.Callable instead of deprecated typing generics."
"typing.ChainMap".msg = "Use collections.ChainMap instead of deprecated typing generics."
"typing.Collection".msg = "Use collections.abc.Collection instead of deprecated typing generics."
"typing.Container".msg = "Use collections.abc.Container instead of deprecated typing generics."
"typing.ContextManager".msg = "Use contextlib.AbstractContextManager instead of deprecated typing generics."
"typing.Coroutine".msg = "Use collections.abc.Coroutine instead of deprecated typing generics."
"typing.Counter".msg = "Use collections.Counter instead of deprecated typing generics."
"typing.DefaultDict".msg = "Use collections.defaultdict instead of deprecated typing generics."
"typing.Deque".msg = "Use collections.deque instead of deprecated typing generics."
"typing.Dict".msg = "Use dict instead of deprecated typing generics."
"typing.FrozenSet".msg = "Use frozenset instead of deprecated typing generics."
"typing.Generator".msg = "Use collections.abc.Generator instead of deprecated typing generics."
"typing.ItemsView".msg = "Use collections.abc.ItemsView instead of deprecated typing generics."
"typing.Iterable".msg = "Use collections.abc.Iterable instead of deprecated typing generics."
"typing.Iterator".msg = "Use collections.abc.Iterator instead of deprecated typing generics."
"typing.KeysView".msg = "Use collections.abc.KeysView instead of deprecated typing generics."
"typing.List".msg = "Use list instead of deprecated typing generics."
"typing.Mapping".msg = "Use collections.abc.Mapping instead of deprecated typing generics."
"typing.Match".msg = "Use re.Match instead of deprecated typing generics."
"typing.MutableMapping".msg = "Use collections.abc.MutableMapping instead of deprecated typing generics."
"typing.MutableSequence".msg = "Use collections.abc.MutableSequence instead of deprecated typing generics."
"typing.MutableSet".msg = "Use collections.abc.MutableSet instead of deprecated typing generics."
"typing.OrderedDict".msg = "Use collections.OrderedDict instead of deprecated typing generics."
"typing.Pattern".msg = "Use re.Pattern instead of deprecated typing generics."
"typing.Reversible".msg = "Use collections.abc.Reversible instead of deprecated typing generics."
"typing.Sequence".msg = "Use collections.abc.Sequence instead of deprecated typing generics."
"typing.Set".msg = "Use set instead of deprecated typing generics."
"typing.Tuple".msg = "Use tuple instead of deprecated typing generics."
"typing.Type".msg = "Use type instead of deprecated typing generics."
"typing.ValuesView".msg = "Use collections.abc.ValuesView instead of deprecated typing generics."
[tool.ruff.lint.pydocstyle]
# Enforce NumPy docstring style
convention = "numpy"
[tool.ruff.lint.pydoclint]
# Concise one-line private helpers do not require structured sections; public
# entrypoints use multiline docstrings so their contracts remain checked.
ignore-one-line-docstrings = true
[tool.ruff.lint.mccabe]
max-complexity = 8
[tool.ruff.lint.pylint]
max-args = 4
max-bool-expr = 2
max-locals = 10
[tool.pylint.main]
# Activate rules whose behaviour depends on the project's Python baseline.
py-version = "3.14"
# Expand directory targets like scripts and tests even when they are not packages.
recursive = true
# Match the project file-size ceiling enforced during review.
max-module-lines = 400
[tool.pylint.design]
# Keep function call surfaces small enough to understand without memorising
# positional argument order.
max-args = 4
# The new Pylint gate complements Ruff's stricter PLR0914 threshold without
# forcing broad refactors while introducing the additional rule families below.
max-locals = 20
# Use Pylint's statement-count proxy for function length; Pylint 4 does not
# expose a distinct physical-lines-per-function option.
max-statements = 70
# Keep positional call surfaces aligned with Ruff's existing argument limit.
max-positional-arguments = 4
[tool.pylint."messages control"]
# Keep this Pylint pass focused on the explicitly selected messages.
disable = [
"all",
]
enable = [
# Catch invalid %-style specifiers before log calls reach production.
"logging-unsupported-format",
# Catch truncated %-style logging templates that cannot be formatted.
"logging-format-truncated",
# Reject log records that pass arguments with no matching placeholders.
"logging-too-many-args",
# Reject log records whose placeholders cannot all be populated.
"logging-too-few-args",
# Preserve lazy logging by passing interpolation values to the logger.
"logging-not-lazy",
# Discourage eager str.format calls in logging statements.
"logging-format-interpolation",
# Discourage eager f-string interpolation in logging statements.
"logging-fstring-interpolation",
# Prevent bare match captures from making later cases unreachable.
"bare-name-capture-pattern",
# Ensure class pattern matching metadata has the required shape.
"invalid-match-args-definition",
# Catch positional class patterns that exceed declared __match_args__.
"too-many-positional-sub-patterns",
# Reject duplicate attribute patterns in one class match.
"multiple-class-sub-patterns",
# Prefer whole-pattern class binding when that avoids extra lookups.
"match-class-bind-self",
# Prefer explicit keyword class patterns over positional attributes.
"match-class-positional-attributes",
# Keep adjacent isinstance checks compact and easier to scan.
"consider-merging-isinstance",
# Flag deeply nested control flow before functions become hard to audit.
"too-many-nested-blocks",
# Replace boolean-only if statements with direct boolean expressions.
"simplifiable-if-statement",
# Catch local bindings that accidentally shadow function parameters.
"redefined-argument-from-local",
# Remove redundant else blocks after unconditional returns.
"no-else-return",
# Prefer explicit ternary expressions over pre-ternary idioms.
"consider-using-ternary",
# Catch accidental one-item tuples caused by stray trailing commas.
"trailing-comma-tuple",
# Avoid StopIteration escaping generators under PEP 479.
"stop-iteration-return",
# Simplify redundant boolean expressions.
"simplify-boolean-expression",
# Keep return contracts explicit and consistent within each function.
"inconsistent-return-statements",
# Remove terminal return None statements that add no behaviour.
"useless-return",
# Prefer tuple unpacking for variable swaps.
"consider-swap-variables",
# Prefer str.join for iterable string assembly.
"consider-using-join",
# Prefer membership checks over repeated equality comparisons.
"consider-using-in",
# Prefer dict.get when retrieving optional dictionary values.
"consider-using-get",
# Prefer chained comparisons for ordered relationships.
"chained-comparison",
# Prefer dictionary comprehensions over dict(list-comprehension) patterns.
"consider-using-dict-comprehension",
# Prefer set comprehensions over set(list-comprehension) patterns.
"consider-using-set-comprehension",
# Simplify boolean-only conditional expressions.
"simplifiable-if-expression",
# Remove redundant else blocks after unconditional raises.
"no-else-raise",
# Replace identity comprehensions with direct collection constructors.
"unnecessary-comprehension",
# Prefer sys.exit for explicit process termination.
"consider-using-sys-exit",
# Remove redundant else blocks after unconditional breaks.
"no-else-break",
# Remove redundant else blocks after unconditional continues.
"no-else-continue",
# Prefer Python 3 super() without explicit class and instance arguments.
"super-with-arguments",
# Simplify boolean conditions that have redundant structure.
"simplifiable-condition",
# Catch conditions that statically evaluate to constants.
"condition-evals-to-constant",
# Prefer generators when a container is only consumed immediately.
"consider-using-generator",
# Avoid unnecessary comprehensions inside any/all/min/max/sum.
"use-a-generator",
# Prefer min() over equivalent conditional assignments.
"consider-using-min-builtin",
# Prefer max() over equivalent conditional assignments.
"consider-using-max-builtin",
# Encourage context managers for resource-owning operations.
"consider-using-with",
# Avoid redundant dictionary lookups while iterating items.
"unnecessary-dict-index-lookup",
# Prefer [] for empty list creation.
"use-list-literal",
# Prefer {} for dictionary creation when a literal is clearer.
"use-dict-literal",
# Avoid redundant list index lookups while enumerating values.
"unnecessary-list-index-lookup",
# Prefer yield from for delegating iterable output.
"use-yield-from",
# Remove double negatives from boolean expressions.
"unnecessary-negation",
# Prefer enumerate over range(len(...)) loops.
"consider-using-enumerate",
# Iterate dictionaries directly instead of through keys().
"consider-iterating-dictionary",
# Prefer dict.items() when both keys and values are used.
"consider-using-dict-items",
# Use maxsplit when only the first or last split component is needed.
"use-maxsplit-arg",
# Prefer sequence literals for repeated iteration values.
"use-sequence-for-iteration",
# Prefer f-strings for non-logging eager string interpolation.
"consider-using-f-string",
# Prefer direct sequence truthiness over len(sequence).
"use-implicit-booleaness-not-len",
# Prefer direct sequence truthiness over comparison to an empty literal.
"use-implicit-booleaness-not-comparison",
# Prefer direct string truthiness over comparison to an empty string.
"use-implicit-booleaness-not-comparison-to-string",
# Prefer operators and builtins over direct dunder calls.
"unnecessary-dunder-call",
# Avoid placeholder ellipses when a concrete stub body is clearer.
"unnecessary-ellipsis",
# Ensure environment helper calls receive string values.
"invalid-envvar-value",
# Use singledispatchmethod for method dispatch.
"singledispatch-method",
# Use singledispatch for function dispatch.
"singledispatchmethod-function",
# Catch invalid file open modes early.
"bad-open-mode",
# Preserve compatibility awareness for datetime.time truthiness checks.
"boolean-datetime",
# Catch unittest assertions that cannot fail.
"redundant-unittest-assert",
# Ensure threading.Thread receives the target argument intentionally.
"bad-thread-instantiation",
# Prefer os.environ.copy() over shallow-copying the environment proxy.
"shallow-copy-environ",
# Ensure os.getenv defaults have the expected string-or-None shape.
"invalid-envvar-default",
# Avoid preexec_fn because it can deadlock in threaded programs.
"subprocess-popen-preexec-fn",
# Require explicit subprocess.run check semantics.
"subprocess-run-check",
# Require explicit encodings for file I/O portability.
"unspecified-encoding",
# Keep breakpoint hooks out of committed code.
"forgotten-debug-statement",
# Avoid unbounded method caches that retain self indefinitely.
"method-cache-max-size-none",
# Surface deprecated stdlib method usage.
"deprecated-method",
# Surface deprecated stdlib argument usage.
"deprecated-argument",
# Surface deprecated stdlib class usage.
"deprecated-class",
# Surface deprecated stdlib decorator usage.
"deprecated-decorator",
# Surface deprecated stdlib attribute usage.
"deprecated-attribute",
# Flag modules that have grown large enough to deserve splitting.
"too-many-lines",
# Keep trailing whitespace out of Python sources.
"trailing-whitespace",
# Require final newlines for stable text-file handling.
"missing-final-newline",
# Avoid excess blank lines at file end.
"trailing-newlines",
# Remove redundant parentheses around control-flow keywords.
"superfluous-parens",
# Catch mixed line endings before they create noisy diffs.
"mixed-line-endings",
# Enforce the configured line-ending format.
"unexpected-line-ending-format",
# Prevent mutating dictionaries while iterating them.
"modified-iterating-dict",
# Prevent mutating sets while iterating them.
"modified-iterating-set",
# Flag list mutation during iteration, where behaviour is easy to miss.
"modified-iterating-list",
# Keep public class surfaces small enough to understand.
"too-many-public-methods",
# Flag branch-heavy functions for refactoring.
"too-many-branches",
# Keep function signatures from accumulating too many parameters.
"too-many-arguments",
# Flag functions whose local state has become hard to follow.
"too-many-locals",
# Flag functions that do too much sequential work.
"too-many-statements",
# Keep compound boolean conditions readable.
"too-many-boolean-expressions",
# Keep positional call surfaces small and explicit.
"too-many-positional-arguments",
]