Skip to content

Improve docs on config file precedence #18034

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

Closed
wants to merge 1 commit into from

Conversation

timhoffm
Copy link

When working with ruff, I fell into the trap of having .ruff.toml and pyproject.toml config files. It took me some time to find the precedence rules from the docs. This PR aims to make the docs slightly more clear.

  • In the section "Config file discovery" the precedence was described quite lengthy at the very end of the section. I propose it's more concise to describe this with a single sentence immediately after stating that there can be one config file per directory.
  • At the very top, when listing all config file types, list them in the order of their precedence. Being equal otherwise, matching the order of precendence may alreay be a subtle hint to users.

@ntBre ntBre added the documentation Improvements or additions to documentation label May 12, 2025
Comment on lines -305 to -309
All of the above rules apply equivalently to `pyproject.toml`, `ruff.toml`, and `.ruff.toml` files.
If Ruff detects multiple configuration files in the same directory, the `.ruff.toml` file will take
precedence over the `ruff.toml` file, and the `ruff.toml` file will take precedence over
the `pyproject.toml` file.

Copy link
Member

Choose a reason for hiding this comment

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

I prefered this phrasing because it is more specific about when the precedence applies (it applies on a per directory level)

Copy link
Author

@timhoffm timhoffm May 13, 2025

Choose a reason for hiding this comment

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

Would it work for you if we keep the exact wording and just move the lines 306-308 up?

When working with ruff, I fell into the trap to have `.ruff.toml` and `pyproject.toml` config files. It took me some time to find the precedence rules from the docs. This PR aims to make the docs slightly more clear.

- In the section "Config file discovery" the precedence was described quite lengthy at the very end of the section. I propose it's more concise to describe this with a single sentence immediately after stating that there can be one config file per directory.
@timhoffm timhoffm force-pushed the doc-config-preference branch from cd9df9a to 89f106f Compare May 22, 2025 19:45
@timhoffm
Copy link
Author

I've kept the original phrasing and just move the text up. Feel free to merge or close depending on what makes more sense to you.

@MichaReiser
Copy link
Member

I slightly prefer the currnet structure. That's why I'll close this PR. But thanks for discussing this change

@timhoffm timhoffm deleted the doc-config-preference branch May 23, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants