From fad38aa9eb3b8ef6ec84982b8b7a9536189c63e6 Mon Sep 17 00:00:00 2001 From: furedea <132188853+furedea@users.noreply.github.com> Date: Sun, 18 Oct 2026 18:19:52 +0900 Subject: [PATCH] build(lint): enforce the AGENTS.md size and complexity rules - ruff: max-args = 3 (PLR0913 no longer ignored, tests exempt for pytest fixtures), PLR1702 preview rule with max-nested-blocks = 2, C901 with max-complexity = 10, blanket noqa (PGH004) no longer ignored - lefthook: file-length pre-commit job capping *.py files at 500 lines Refs furedea/dotfiles#213 Co-Authored-By: Claude Opus 5.5 --- lefthook.yml | 8 ++++++++ pyproject.toml | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lefthook.yml b/lefthook.yml index 436a11e..0d3b43e 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -26,3 +26,11 @@ pre-commit: run: uv run ty check ls-lint: run: ls_lint + file-length: + glob: "*.py" + run: | + for f in {staged_files}; do + n=$(wc -l < "$f") + [ "$n" -le 500 ] || { echo "$f: $n lines (max 500)"; fail=1; } + done + exit ${fail:-0} diff --git a/pyproject.toml b/pyproject.toml index 44ff7ed..337eac1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,6 +55,8 @@ indent-style = "space" docstring-code-format = true [tool.ruff.lint] +preview = true +explicit-preview-rules = true select = [ "AIR", "FAST", @@ -99,6 +101,8 @@ select = [ "FURB", "RUF", "INP", + "C901", + "PLR1702", ] ignore = [ "G004", @@ -107,17 +111,25 @@ ignore = [ "ANN401", "ARG002", "INP001", - "PGH004", "B008", "A002", "A003", - "PLR0913", "W191", "E111", "E114", "E117", ] +[tool.ruff.lint.per-file-ignores] +"tests/**" = ["PLR0913"] + +[tool.ruff.lint.mccabe] +max-complexity = 10 + +[tool.ruff.lint.pylint] +max-args = 3 +max-nested-blocks = 2 + [tool.ty.src] include = ["src", "tests"]