chore(lint): ruff config + format sweep + manual cleanup#4
Merged
Conversation
Two test-specific ignores codify codebase conventions that ruff's default profile misfires on: - N802 (function name should be lowercase) ignored under tests/**: test_statusline_formatters.py covers boundaries between SI prefixes (kilo/Mega/Billion/Trillion). test_k_to_M_boundary, test_M_to_B_boundary, test_B_to_T_boundary etc. encode the boundary semantically — lowercasing would lose the prefix-pair meaning. 12 findings ignored. - RUF059 (unused unpacked variable) ignored under tests/**: pytest fixtures often return tuples where individual tests need only one value (e.g. `state_mod, tmp_path = state_env` — some tests use both, some only state_mod). Prefixing every "unused" half with `_` would obscure the fixture contract. 8 findings ignored. Both ignores are scoped to tests/** so unrelated future violations in hooks/, lib/, scripts/ still surface. No blanket noqa, no inline noise. Drops total ruff check findings from 28 to 13. Remaining 13 are real code-smells (F401 unused imports, F841 unused locals, E402 import order) that will be addressed by `ruff check --fix` + targeted manual edits in follow-up commits on this branch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mechanical formatter + linter sweep across the codebase: - `ruff format .` reformatted 77 files (whitespace, line-length, quote style consistency). Pre-existing drift from incremental hand-formatting in earlier sessions; ruff format is now the single source of truth. - `ruff check --fix .` auto-fixed 10 findings (mostly RUF100 unused noqa directives + 1 PTH206 split(os.sep) → Path.parts + 1 PTH101 os.chmod → Path.chmod). All semantic-preserving. 3 findings remain — F841 unused local variable (×2) + E402 module import-not-at-top (×1). These need targeted manual review and follow in the next commit on this branch. Verified: - pytest tests/ — 646 green (full regression intact) - ruff format --check . — clean - ruff check . — 3 remaining (manual, intentional) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three findings that the auto-fixer left for manual judgment:
- tests/test_session_start.py:45 F841 `filtered`: dead code from a
prior PATH-filtering strategy that was abandoned mid-write (the
comment "Actually this is brittle; let's use a different approach"
on line 52 documents the pivot). The replacement strategy on line 56
(env["PATH"] = tempfile.gettempdir()) does the actual job. Removed
the dead block + tightened the surrounding comment.
- tests/test_session_state.py:43 F841 `pc`: `pc = s.get("prompt_count")`
with no follow-up assertion or use. Likely a debug-leftover; the
subsequent s.set/save/reload assertions cover the actual contract.
Removed.
- tests/test_token_audit.py:35 E402 `import tempfile`: the import was
placed mid-module under the pretext of "must set before exec_module
because module-level code reads env" — but the env-set is on line 38
(after the import); the import itself has no env-side-effect. Moved
`import tempfile` to the top with the rest of stdlib imports and
trimmed the misleading comment.
ruff check: 0 findings. ruff format: clean. pytest tests/: 646 green.
harden.py: 0 critical.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Documents Session D Phase 1+1.5+2+3 work: - state.py path-traversal validation (TASK-2026-00679) - state.py atomic save (TASK-2026-00680) - state.py file-lock + RMW + dirty-tracking (Codex finding) - get() docstring contract (Codex minor) - ruff.toml per-file-ignores for tests/** - 77-file format sweep + 10 auto-fixes + 3 manual fixes Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Internal lint hygiene sweep for Session D Phase 3. Three concerns kept atomic:
ruff.tomlconfig (commit354eae7) — per-file-ignores fortests/**codifying conventions (N802 SI-prefix naming, RUF059 pytest fixture tuples). Both ignores scoped narrowly so hooks/lib/scripts retain full default profile.Format + auto-fix sweep (commit
e6b6dac) —ruff formatreformatted 77 files;ruff check --fixcleared 10 findings (RUF100 unused noqa, PTH206/PTH101 modernization).Manual remaining (commit
05515c1) — 3 findings the auto-fixer left for human judgment:tests/test_session_start.py:45F841filtered— dead code from abandoned strategytests/test_session_state.py:43F841pc— debug-leftovertests/test_token_audit.py:35E402import tempfile— moved to topCHANGELOG (commit
ea19874) — v4.4.1 entry documenting state hardening (PR fix(state): hardening — path-traversal validation + atomic save (v4.4.1) #3 already merged) + this lint sweep.End state
ruff format --check .— cleanruff check .— 0 findings (was 28)pytest tests/— 646 greenharden.py --scan— 0 criticalTest Plan
Plan reference
~/.claude/plans/jaundder-plan-hashed-tiger.mdPhase 3.🤖 Generated with Claude Code