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

Stop at the first resolved parent configuration #8864

Merged
merged 3 commits into from
Nov 29, 2023
Merged

Stop at the first resolved parent configuration #8864

merged 3 commits into from
Nov 29, 2023

Conversation

MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Nov 28, 2023

Summary

This is a potential fix for #8858 but requires some more testing.
I'm throwing this out here to get some feedback on whether this seems correct. The following is my reasoning, although I'm not very familiar with the code.

The idea of visiting all ancestor paths is to find a configuration for the current directory (or given path).
Visiting the ancestors is necessary if the configuration happens to be in a parent directory. For example when running ruff in a sub-directory of the project.

This PR changes the implementation to stop at the first found configuration instead of visiting the entire project chain.
One potential issue this could introduce is:

root:
  - pyproject.toml (excludes subdir)
  - subdir
    - pyproject.toml
      - sub-sub-dir
        - some-python files 

Running ruff in sub-sub-dir would lint no files in the old version because the files are excluded by the root pyproject.toml.
The new version lints the files in the sub-sub-dir because it finds the subdir/pyproject.toml as the closest pyproject.toml and it
does not exclude the directoy.

The new behavior seems more correct to me, but I might be overlooking something.

Fixes #8858

Test Plan

Added regression test.

@MichaReiser
Copy link
Member Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@MichaReiser MichaReiser added the cli Related to the command-line interface label Nov 28, 2023
@MichaReiser
Copy link
Member Author

This is a potential breaking change

Copy link
Contributor

github-actions bot commented Nov 28, 2023

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct to me.

@MichaReiser MichaReiser enabled auto-merge (squash) November 29, 2023 04:19
@MichaReiser MichaReiser merged commit cddc696 into main Nov 29, 2023
16 checks passed
@MichaReiser MichaReiser deleted the fix-8858 branch November 29, 2023 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the command-line interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Config file discovery incorrectly includes parent config
2 participants