Skip to content

feat(script): Apply framework ruff ignores to subdirectories, scoped to them - #197

Merged
jpmckinney merged 1 commit into
mainfrom
framework-ignores-subdirectories
Sep 28, 2026
Merged

jpmckinney merged 1 commit into
mainfrom
framework-ignores-subdirectories

Conversation

@jpmckinney

Copy link
Copy Markdown
Member

tests/script.sh detects frameworks only from the root requirements.txt or pyproject.toml. When a repository's root is not Django but a subdirectory is (e.g. a Django app in prototype/ with its own pyproject.toml), the app is linted as plain Python. It then reports PT009, DJ008, RUF012 and similar findings that Django repositories normally ignore.

This PR moves the framework checks into a function, add_framework_ignores FILE PREFIX, and also calls it for each subdirectory with a tracked requirements.txt or pyproject.toml (skipping docs/, which is for Read the Docs). For the root, behaviour is unchanged. For a subdirectory, rules are added as per-file ignores (prototype/*:PT) and patterns are prefixed (prototype/*/views.py:ARG001), so a non-Django root does not have PT, DJ008 or S308 ignored repository-wide. Glob metacharacters in the directory name are escaped, so cookiecutter directories like {{cookiecutter.project_slug}} match.

Tested:

  • A private repository with a Django app in a subdirectory: PT009 71 -> 0, PT027 2 -> 0, DJ008 6 -> 0, RUF012 11 -> 1. Other rules are unchanged.
  • data-registry, credere-backend, standard-maintenance-scripts: the generated ruff arguments are identical before and after.
  • software-development-handbook: only adds Django ignores scoped to the cookiecutter directory, and 'id'.
  • The ruff glob behaviour (root-anchored patterns, * crossing /, escaping {{…}}) was checked with ruff 0.16.8. The script passes shellcheck and behaves the same under macOS's /bin/bash 3.2.

Limitations:

  • The builtins ignorelist can't be set per file, so 'id' from a Django subdirectory still applies repository-wide.
  • Only the framework checks run per subdirectory; other ignores (e.g. tests/*:S) remain root-relative.
  • A subdirectory is detected only by a tracked requirements.txt or pyproject.toml.

🤖 Generated with Claude Code

…to them

Frameworks were detected only from the root requirements.txt or
pyproject.toml, so a Django app in a subdirectory of a non-Django
repository was linted as plain Python. The framework checks now also run
for each subdirectory with a tracked requirements.txt or pyproject.toml
(except docs/), adding their ignores as per-file ignores scoped to that
subdirectory. Root behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018pPWf7D2NRSLYtLVbrCXt7
@jpmckinney
jpmckinney merged commit 130a7df into main Sep 28, 2026
11 checks passed
@jpmckinney
jpmckinney deleted the framework-ignores-subdirectories branch September 28, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant