R342 Run a Python project’s lint and lock file check in the commit hooks
Run the formatter, linter and docstring checker that a Python project configures, and the check that its lock file is current, in the repository’s commit hooks.
Reason
A check that runs only when someone remembers to run it catches mistakes only then; in the hooks, these fast checks stop a mistake before it is committed (Art. III §1(2)). The type check and the tests stay out of the hooks, which rule 250 keeps to checks that take seconds.
Verification
What the hooks run is read from their configuration. A project configures a tool when the tool is in its dependency groups with settings for it; whether a project must have a docstring checker at all is for rule 341, not this rule. The lock file check is one that fails when the lock file no longer matches the project file, such as the uv-lock hook; a project that keeps no lock file needs none. A gap that is already there when a repository enables this rule is broken only by a change that touches it, as below, so that unrelated changes are not in breach.
Violated when a change adds a Python project, adds a formatter, linter or docstring checker to one, or changes the commit hook configuration, and after the change the hooks do not run one of these checks, or the lock file check, for a Python project in the repository.