python/module-too-large
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| Python | warning | none, edit by hand | All versions |
Modules that grow past the fixed 300-statement limit accumulate duplicated pipelines and dead code unnoticed. Delete repeated or dead code until the module fits within the limit.
What the rule reports
Section titled “What the rule reports”The rule counts all executable statements in a Python module (excluding comments and docstrings) against a fixed 300-statement limit.
Existing oversized modules can be recorded at their current statement count under [tool.xpd.ratchet] in pyproject.toml:
[tool.xpd.ratchet."src/pipeline.py"]statements = 420Recorded ceilings may only shrink. Adding statements above the ceiling, leaving a stale ceiling after shrinking, adding a new file to an existing ratchet, or raising a ceiling relative to git HEAD all fail the rule.
How to fix it
Section titled “How to fix it”Run xpd check --fix after deleting statements. It lowers an existing module ceiling and updates recorded functions that shrank or disappeared. When the module fits the 300-statement limit and every function fits the 50-statement limit, it removes the entry. If the module fits but only unrecorded functions exceed their limit, shrink those functions before running the fix.
Diagnostic message
Section titled “Diagnostic message”This module exceeds the fixed 300-statement limit. Delete repeated or dead code until the module fits within the limit.See all rules in the Python pack.