Skip to content

Commit 20a4f84

Browse files
physicsrobclaude
andcommitted
Ruff migration: config, deps, Makefile (black -> ruff, select ALL)
Replace black with ruff==0.15.22 (pinned exactly: ALL picks up new rules on upgrade). Ignore list defends deliberate decisions only: S101 (I1-I4 invariant asserts), T201 (probe tooling prints by contract), N802/3/6 (Q/K/V math naming), PLC0415 (lazy heavy imports), plus formatter conflicts, deferred docstring-presence rules, and exception-message style. Lock regenerated via make modal-lock. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 6576300 commit 20a4f84

3 files changed

Lines changed: 74 additions & 96 deletions

File tree

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ compile: $(HF_BUNDLES)
1111

1212
.PHONY: lint
1313
lint:
14-
uv run black --check .
14+
uv run ruff format --check .
15+
uv run ruff check .
1516
uv run mypy .
1617

1718
# Guard the standalone lock the Modal --frozen build installs from. It cannot

pyproject.toml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ hf = [
3131

3232
[dependency-groups]
3333
dev = [
34-
"black",
34+
# Pinned exactly: select = ["ALL"] picks up new rules on upgrade, so a
35+
# ruff bump is a deliberate act (bump pin + fix new violations together).
36+
"ruff==0.15.22",
3537
"modal",
3638
"mypy",
3739
"pytest",
@@ -77,3 +79,45 @@ show_missing = true
7779

7880
[tool.mypy]
7981
ignore_missing_imports = true
82+
83+
[tool.ruff]
84+
# target-version is inferred from requires-python (>=3.10).
85+
line-length = 88
86+
87+
[tool.ruff.lint]
88+
select = ["ALL"]
89+
# Every entry here defends a deliberate torchwright decision, not a backlog.
90+
# Do not add entries to make a check pass — fix the code instead.
91+
ignore = [
92+
# Formatter conflicts (ruff's own recommendation when using its formatter)
93+
"COM812", # missing-trailing-comma
94+
"ISC001", # single-line-implicit-string-concatenation
95+
# Docstring presence — deferred as a separate task; shape rules (D2xx) stay on
96+
"D100", "D101", "D102", "D103", "D104", "D105", "D106", "D107",
97+
# Exception-message style rules that fight the long, diagnostic messages
98+
# this codebase deliberately writes
99+
"TRY003", # long messages in exception constructors
100+
"EM101", "EM102", # string literals / f-strings in exceptions
101+
# Compiler invariants I1-I4 are runtime asserts by doctrine (CLAUDE.md,
102+
# "Compiler Invariants"): AssertionError shape is pinned by negative tests
103+
"S101", # use of assert
104+
# The probe/watch debug tooling prints by contract ("prints, does not raise")
105+
"T201", # print
106+
# Math naming: Q/K/V/W matrices in a transformer compiler
107+
"N802", "N803", "N806",
108+
# Lazy imports of heavy deps (torch/onnx/modal) are deliberate
109+
"PLC0415", # import-outside-top-level
110+
]
111+
112+
[tool.ruff.lint.pydocstyle]
113+
convention = "google"
114+
115+
[tool.ruff.lint.per-file-ignores]
116+
"tests/**" = [
117+
"PLR2004", # magic values allowed in tests
118+
"ANN", # type annotations optional in tests
119+
"SLF001", # private-member access allowed in tests
120+
]
121+
122+
[tool.ruff.format]
123+
docstring-code-format = true

0 commit comments

Comments
 (0)