feat(script): Apply framework ruff ignores to subdirectories, scoped to them - #197
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tests/script.shdetects frameworks only from the rootrequirements.txtorpyproject.toml. When a repository's root is not Django but a subdirectory is (e.g. a Django app inprototype/with its ownpyproject.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 trackedrequirements.txtorpyproject.toml(skippingdocs/, 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:
'id'.*crossing/, escaping{{…}}) was checked with ruff 0.16.8. The script passes shellcheck and behaves the same under macOS's/bin/bash3.2.Limitations:
'id'from a Django subdirectory still applies repository-wide.tests/*:S) remain root-relative.requirements.txtorpyproject.toml.🤖 Generated with Claude Code