Skip to content

chore(lint): ruff config + format sweep + manual cleanup#4

Merged
LEEI1337 merged 4 commits into
mainfrom
chore/lint-sweep
May 2, 2026
Merged

chore(lint): ruff config + format sweep + manual cleanup#4
LEEI1337 merged 4 commits into
mainfrom
chore/lint-sweep

Conversation

@LEEI1337

@LEEI1337 LEEI1337 commented May 2, 2026

Copy link
Copy Markdown
Member

Summary

Internal lint hygiene sweep for Session D Phase 3. Three concerns kept atomic:

  1. ruff.toml config (commit 354eae7) — per-file-ignores for tests/** codifying conventions (N802 SI-prefix naming, RUF059 pytest fixture tuples). Both ignores scoped narrowly so hooks/lib/scripts retain full default profile.

  2. Format + auto-fix sweep (commit e6b6dac) — ruff format reformatted 77 files; ruff check --fix cleared 10 findings (RUF100 unused noqa, PTH206/PTH101 modernization).

  3. Manual remaining (commit 05515c1) — 3 findings the auto-fixer left for human judgment:

    • tests/test_session_start.py:45 F841 filtered — dead code from abandoned strategy
    • tests/test_session_state.py:43 F841 pc — debug-leftover
    • tests/test_token_audit.py:35 E402 import tempfile — moved to top
  4. CHANGELOG (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 . — clean
  • ruff check .0 findings (was 28)
  • pytest tests/646 green
  • harden.py --scan — 0 critical
  • 80 files touched (config + format + cleanup + changelog) — under 100-file safety threshold

Test Plan

Plan reference

~/.claude/plans/jaundder-plan-hashed-tiger.md Phase 3.

🤖 Generated with Claude Code

ai-engineering.at and others added 4 commits May 2, 2026 20:44
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>
@LEEI1337 LEEI1337 merged commit 1a42adb into main May 2, 2026
7 checks passed
@LEEI1337 LEEI1337 deleted the chore/lint-sweep branch May 2, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant