Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support hierarchical settings for nested directories #1190

Merged
merged 1 commit into from
Dec 12, 2022

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Dec 11, 2022

The goal of this PR is to introduce hierarchical settings detection for Ruff, similar to the ESLint model, such that when we go to lint a given file, we always use the pyproject.toml file "closest" to that file in the filesystem hierarchy.

This has a number of nice side effects -- namely, linting a file becomes independent of the path from which the linter was invoked, and independent of the list of files passed to the ruff invocation (neither of which are true today).

(There's one caveat here which is that the fix and format pyproject.toml options, which are semantically part of the invocation, aren't going to be inherited -- so we'll use the current working directory to find the pyproject.toml to power those two, specific options.)

Resolves #1069.

@charliermarsh charliermarsh marked this pull request as draft December 11, 2022 03:41
@charliermarsh charliermarsh force-pushed the charlie/configuration-i branch 5 times, most recently from a2784c5 to 7d7e227 Compare December 11, 2022 03:54
@charliermarsh charliermarsh marked this pull request as ready for review December 11, 2022 03:54
@charliermarsh
Copy link
Member Author

There's a small performance hit here from doing two filesystem traversals. It might be possible to avoid it, since we could in theory track the "current" pyproject.toml as we iterate over the Python files (we need to know the current settings in order to power the excludes behavior).

@charliermarsh charliermarsh merged commit 0adc9ed into main Dec 12, 2022
@charliermarsh charliermarsh deleted the charlie/configuration-i branch December 12, 2022 15:12
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.

Surprising config file resolution behavior
1 participant