Skip to content

Stop at the first resolved parent configuration#8864

Merged
MichaReiser merged 3 commits intomainfrom
fix-8858
Nov 29, 2023
Merged

Stop at the first resolved parent configuration#8864
MichaReiser merged 3 commits intomainfrom
fix-8858

Conversation

@MichaReiser
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

This is a potential breaking change

@github-actions
Copy link
Copy Markdown
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
Copy Markdown
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
@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