Skip to content

#19: Python oversized-file via a line-count leaf sensor - #37

Merged
devill merged 2 commits into
mainfrom
issue-19-python-oversized-file
Jun 17, 2026
Merged

#19: Python oversized-file via a line-count leaf sensor#37
devill merged 2 commits into
mainfrom
issue-19-python-oversized-file

Conversation

@devill

@devill devill commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Closes #19.

oversized-file fired for TypeScript (ESLint max-lines) but not Python — there's no clean ruff rule, so it was deferred. This closes the gap, giving the two presets full parity on the smell.

Implementation (locked decision)

A language-agnostic lineCountSensor(maxLines) emits oversized-file for any discovered file whose physical line count exceeds the threshold (no AST needed). The Python preset wires it in.

Threshold sourcing + a ruff finding

The threshold (max-module-lines, default 200, matching TS max-lines) is read from the consumer's config by a no-TOML-parser text scan — the same approach the init drift-check uses.

⚠️ ruff 0.15 rejects max-module-lines as an unknown field under [tool.ruff] (verified: unknown field max-module-lines, expected one of …). So the locked decision's literal "ruff-config-style key in the consumer's ruff config" can't live inside [tool.ruff]. The key is therefore set in a ruff-ignored location (e.g. [tool.habit-hooks] in pyproject.toml); the text scan finds it anywhere. It is intentionally not added to RUFF_RECOMMENDED/the init scaffold, since recommending a key inside a ruff table would break ruff. Documented in DECISIONS.md and docs/smell-vocabulary.md.

Atomic commits

  1. #19: add a language-agnostic line-count sensor — the sensor + unit tests (strictly-over boundary, trailing-newline handling).
  2. #19: emit oversized-file in the Python preset — wire-in, threshold reader, runner cwd thread-through, docs, and acceptance tests.

Tests

  • Sensor unit tests.
  • Python acceptance: a .py file over a configured threshold yields oversized-file; a small file at the default threshold does not. These run without the Python toolchain (line-count needs no tools).

Gates

  • pnpm build, pnpm lint — clean
  • pnpm test — 389 passed (+4)

🤖 Generated with Claude Code


Generated by Claude Code

claude added 2 commits June 17, 2026 17:04
lineCountSensor emits oversized-file for any discovered file whose
physical line count exceeds a threshold. oversized-file is a pure line
count and needs no AST, so this can cover languages with no tool rule
for it. Unwired until the Python preset uses it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq6xHU6JtSNpYWhMYjXB15
(`max-module-lines`, default 200) from the consumer's config via a
no-TOML-parser text scan. ruff 0.15 rejects an unknown `max-module-lines`
key under `[tool.ruff]`, so consumers set it in a ruff-ignored location
(e.g. `[tool.habit-hooks]` in pyproject.toml); documented in
DECISIONS.md and smell-vocabulary.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq6xHU6JtSNpYWhMYjXB15
@devill
devill force-pushed the issue-19-python-oversized-file branch from e5e2c6d to 381a82b Compare June 17, 2026 15:05
@devill
devill marked this pull request as ready for review June 17, 2026 15:06
@devill
devill merged commit b2978b1 into main Jun 17, 2026
2 checks passed
@devill
devill deleted the issue-19-python-oversized-file branch June 19, 2026 12:21
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.

Python preset: detect oversized-file (currently deferred — no clean ruff rule)

2 participants