Skip to content

Commit 24906af

Browse files
physicsrobclaude
andcommitted
Ruff config: record the standing-rule decisions from the migration review
Global ignores added with rationale: PLR0913 (wide keyword-only signatures are the configuration idiom; much of the surface is doom-called), S105/S106/S107 (token = vocabulary token, never a credential), S603/S607 (argv-list subprocess launchers, no satisfying code change exists). tests/**: E402 (importorskip ordering) and ARG001 (fixtures/hooks are name-matched). Per-file ignores with one-line reasons for the complexity leaves (I1-I4-entangled functions and dispatch tables), interface-slot ARG002s, cache choke-point SLF001s, and recorded singles. Removed five # noqa: E402 comments the tests ignore obsoleted. ruff check / ruff format --check / mypy now all pass clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent f2777f1 commit 24906af

6 files changed

Lines changed: 71 additions & 5 deletions

File tree

pyproject.toml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,18 @@ ignore = [
107107
"N802", "N803", "N806",
108108
# Lazy imports of heavy deps (torch/onnx/modal) are deliberate
109109
"PLC0415", # import-outside-top-level
110+
# Wide keyword-only signatures are how this codebase does configuration:
111+
# the compile entry points and ops library take many knobs by design,
112+
# and much of that surface is called by torchwright_doom (2026-07 survey:
113+
# 122 sites, tail to 26 args, all classified honest or public API)
114+
"PLR0913", # too-many-arguments
115+
# "token" in this codebase means vocabulary token (bos_token/eos_token/
116+
# unk_token, format-version tags), never a credential
117+
"S105", "S106", "S107",
118+
# Advisory subprocess rules with no satisfying code change: the Modal
119+
# launchers and git-provenance helpers build argv lists, never shell=True
120+
"S603", # subprocess-without-shell-equals-true
121+
"S607", # start-process-with-partial-path
110122
]
111123

112124
[tool.ruff.lint.pydocstyle]
@@ -117,7 +129,61 @@ convention = "google"
117129
"PLR2004", # magic values allowed in tests
118130
"ANN", # type annotations optional in tests
119131
"SLF001", # private-member access allowed in tests
132+
"E402", # pytest.importorskip must precede the imports it guards
133+
"ARG001", # pytest fixtures/hooks are resolved by parameter name
120134
]
135+
# Complexity leaves (2026-07 wave-2 review): functions where helper
136+
# extraction would move code across the I1-I4 assertion points, plus
137+
# if/elif dispatch tables where splitting only relocates the table.
138+
"torchwright/compiler/forward/add_placement.py" = ["C901"]
139+
"torchwright/compiler/forward/compile.py" = ["C901", "PLR0912", "PLR0915"]
140+
"torchwright/compiler/forward/cpsat_scheduler.py" = [
141+
"C901", "PLR0912", "PLR0915",
142+
"SLF001", # documented cache injection into Node._live_weight_row_ranges
143+
]
144+
"torchwright/compiler/forward/residual_map.py" = [
145+
"C901", # _check_invariants IS the I1 assertion body
146+
"ARG002", # free/hold's `mech` is a documented subclass interface slot
147+
]
148+
"torchwright/compiler/forward/scheduler.py" = ["C901", "PLR0912", "PLR0915"]
149+
"torchwright/compiler/forward/weight_writer.py" = ["C901", "PLR0912", "PLR0915"]
150+
"torchwright/graph/affine_rules.py" = [
151+
"C901", # compute_affine_bound is a node-type dispatch table
152+
"SLF001", # refresh_node_caches is the designated cache-write choke point
153+
]
154+
"scripts/measure_op_noise.py" = ["PLR0915"] # render_markdown doc-table pipeline
155+
"tests/compile/forward/test_cpsat_intralayer.py" = ["C901"] # mirrors production warm-start loop
156+
"tests/compile/test_graph_clone.py" = [
157+
"C901", # per-field comparator dispatch table
158+
"BLE001", # generic field comparator's deliberate fallback
159+
]
160+
# Interface slots and recorded design decisions
161+
"torchwright/compiler/export.py" = [
162+
"ARG002", # empty_past's max_len: call-site symmetry with ONNX runtime
163+
"ANN401", # **attrs at ONNX make_node emission is genuinely dynamic
164+
]
165+
"torchwright/compiler/forward/cpsat_snapshot.py" = [
166+
"BLE001", # _git_commit is best-effort provenance by contract
167+
"ANN401", # SchedulingProblem._replace passthrough
168+
]
169+
"torchwright/compiler/hf/build.py" = ["PTH100"] # abspath: symlink semantics differ from resolve()
170+
"torchwright/compiler/hf/modeling_torchwright_custom.py" = ["ARG002"] # HF forward() interface kwargs
171+
"torchwright/compiler/hf/tokenization_torchwright_custom.py" = ["FBT001", "FBT002"] # transformers override signature
172+
"torchwright/compiler/realization.py" = ["SLF001"] # live_weight_row_ranges owns its memo cache
173+
"torchwright/compiler/transformer.py" = ["ARG002"] # past_len: accepted-and-ignored interface slot
174+
"torchwright/debug/probe.py" = ["ANN401"] # past_kvs differs structurally per backend
175+
"torchwright/graph/misc.py" = ["ARG002"] # Node.compute keyword contract on constant nodes
176+
"torchwright/graph/node.py" = ["PLW0603"] # module-level node-id counter, reset by tests
177+
# Op names deliberately mirror the builtins they implement for graph nodes
178+
"torchwright/ops/relu/arithmetic_ops.py" = ["A001"]
179+
"torchwright/ops/swiglu/arithmetic_ops.py" = ["A001"]
180+
"torchwright/ops/swiglu/__init__.py" = ["A004"]
181+
"tests/hf/test_calculator_parity.py" = ["S307"] # eval() of arithmetic expressions is the oracle
182+
"scripts/arithmetic_scaling.py" = [
183+
"SLF001", # recorded reach-in: scratchpad private ops for the viz panel
184+
"FBT003", # matplotlib ax.grid(True)
185+
]
186+
"scripts/calculator_layer_table.py" = ["BLE001"] # records any build refusal as a data row
121187

122188
[tool.ruff.format]
123189
docstring-code-format = true

tests/debug/test_ffn_onnx_debug.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
onnxruntime = pytest.importorskip("onnxruntime")
2020

21-
from torchwright.debug.onnx_debug import OnnxDebugSession # noqa: E402
21+
from torchwright.debug.onnx_debug import OnnxDebugSession
2222

2323
D = 256
2424
D_HEAD = 16

tests/debug/test_no_bias_onnx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
onnxruntime = pytest.importorskip("onnxruntime")
2626

27-
from torchwright.debug.onnx_debug import OnnxDebugSession # noqa: E402
27+
from torchwright.debug.onnx_debug import OnnxDebugSession
2828

2929
D = 256
3030
D_HEAD = 16

tests/debug/test_onnx_debug_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
onnxruntime = pytest.importorskip("onnxruntime")
4646

47-
from torchwright.debug.onnx_debug import OnnxDebugSession # noqa: E402
47+
from torchwright.debug.onnx_debug import OnnxDebugSession
4848

4949
D = 1024
5050
D_HEAD = 16

tests/debug/test_swish_onnx_debug.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
onnxruntime = pytest.importorskip("onnxruntime")
2626

27-
from torchwright.debug.onnx_debug import OnnxDebugSession # noqa: E402
27+
from torchwright.debug.onnx_debug import OnnxDebugSession
2828

2929
D = 256
3030
D_HEAD = 16

tests/docs/test_ort_cpu_saturation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
ort = pytest.importorskip("onnxruntime")
4141

42-
from onnx import TensorProto, helper # noqa: E402
42+
from onnx import TensorProto, helper
4343

4444
#: The module hinge-sharpening constant (test_swish_constants.SCALE).
4545
SCALE = 128.0

0 commit comments

Comments
 (0)