Linting as codified practice
P31.linting-contracts.01 · Audience: guest, it-ml, language-pro
A linter is not nitpicking — it is a pile of small, codified opinions over your
code's syntax tree, half of which catch real bugs. This module builds one such
rule with ast, then asks you to make the case for linting as a team contract.
ⓘ Concept: ruff is hundreds of these
ast.parse turns source text into a syntax tree; a lint rule walks it looking for a pattern. A bare except: is an ExceptHandler node whose type is None — the rule ruff calls E722, a few lines of ast. ruff is a fast implementation of hundreds of them, with --fix for the mechanical ones.Why it matters — Once you've written one rule you see linting for what it is — automated, codified review — not arbitrary style policing.
Ask the mentor about this module
Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.
🎓 Practice ladder
2 graded rungs · ~18 minWrite a real lint rule with ast, then argue for linting as a
codified team contract.
Rung 1 — write a lint rule with ast
Loading exercise…
Rung 2 — linting as a codified team contract (interview)
Loading exercise…
Types, error design, and codified style — with P30's tests, that is the whole Correctness & Quality domain: code that stays correct as it grows.
Where next?
Go up a level