From 3171595940a93f24b4e3af56d665cb94ff7dcfc1 Mon Sep 17 00:00:00 2001 From: Bluscream Date: Fri, 18 Sep 2026 12:56:12 +0200 Subject: [PATCH] fix(python): PLR0915 counts statements, not lines Verified with `ruff rule PLR0915`: it is `too-many-statements` (default 50), not a line-length rule. Ruff has no line-based function-length rule at all. python.md now says so and points both limits at a pytest case; coding-dev.md gains the general distinction between a real length lint and a proxy. Co-Authored-By: Claude Opus 5 --- code-languages/python.md | 8 +++++--- coding-dev.md | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/code-languages/python.md b/code-languages/python.md index 8d77808..4df7d6e 100644 --- a/code-languages/python.md +++ b/code-languages/python.md @@ -132,9 +132,11 @@ When talking to a rate-limited API (a chat platform, a store, a tracker): installable package** with its own repo and version, consumed as a dependency. - Keep persistent state in the framework's own config/storage system so it survives restarts; do not invent a parallel JSON file beside it. -- File and function size limits from the general rules apply — Ruff's `PLR0915` covers - function length; put the file limit in a pytest case (see - [`coding-dev.md` §4](skills-public/coding-dev.md)). +- File and function size limits from the general rules apply. Ruff has **no line-based** + function-length rule — `PLR0915` (`too-many-statements`, default 50) and `C901` + (cyclomatic complexity) are the closest proxies and are worth enabling, but neither + measures lines. Put **both** the function-length and file-length limits in a pytest + case (see [`coding-dev.md` §4](skills-public/coding-dev.md)). --- diff --git a/coding-dev.md b/coding-dev.md index 6af38c3..aaa1172 100644 --- a/coding-dev.md +++ b/coding-dev.md @@ -147,8 +147,10 @@ depends on those. A limit nobody checks is a suggestion. Pick the **highest** applicable option: 1. **A linter rule**, where one exists — the function limit is usually covered natively - (Clippy's `too_many_lines`, ESLint's `max-lines-per-function`, `golangci-lint`'s `funlen`, - Ruff's `PLR0915`). A function that trips it wants extracting, not a suppression. + (Clippy's `too_many_lines`, ESLint's `max-lines-per-function`, `golangci-lint`'s `funlen`). + A function that trips it wants extracting, not a suppression. Note that some linters only + offer *proxies* for length — Ruff's `PLR0915` counts statements, not lines — in which case + enable the proxy and put the real limit in a test. 2. **A test**, for anything the linter does not cover — file length almost always falls here. A test is the best home for it: it runs with the suite everyone already runs, it needs no extra tooling, it fails with a message naming the offending files, and it travels with the