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

Ignore pyproject.toml missing tool.black section #4204

Merged
merged 4 commits into from Feb 2, 2024

Conversation

hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Feb 2, 2024

Fixes #2863

This is pretty desirable in a monorepo situation where you have configuration in the root since it will mean you don't have to reconfigure every project.

The good news for backward compatibility is that find_project_root continues to stop at any git or hg root, so in all cases repo root coincides with a pyproject.toml missing tool.black, we'll continue to have the project root as before and end up using default config as before (i.e. we're unlikely to randomly start using the user config).

The other thing we need to be a little careful about is that changing find_project_root logic affects what exclude is relative to. Since we only change in cases where there is no config, this only applies where users were using exclude via command line arg (and had pyproject.toml missing tool.black in a dir that was not repo root).

Finally, for the few who could be affected, the fix is to put an empty [tool.black] in pyproject.toml

hauntsaninja and others added 2 commits February 1, 2024 19:14
Fixes psf#2863

This is pretty desirable in a monorepo situation where you have
configuration in the root since it will mean you don't have to
reconfigure every project.

The good news for backward compatibility is that `find_project_root`
continues to stop at any git or hg root, so in all cases repo root
coincides with a pyproject.toml missing tool.black, we'll continue to
have the project root as before and end up using default config
(i.e. we're unlikely to randomly start using the user config).

The other thing we need to be a little careful about is that changing
find_project_root logic affects what `exclude` is relative to.  Since we
only change in cases where there is no config, this only applies where
users were using `exclude` via command line arg (and had pyproject.toml
missing tool.black in a dir that was not repo root).

Finally, for the few who could be affected, the fix is to put an empty
`[tool.black]` in pyproject.toml
@hauntsaninja
Copy link
Collaborator Author

This has some relation to #1826 in that this gives some folks affected by that issue an option (assuming it's all within the same repo, have pyproject.toml in a parent directory). However, I don't really like #1826 on its own — without #3952 I think it's a little footgun-y.

Copy link

github-actions bot commented Feb 2, 2024

diff-shades reports zero changes comparing this PR (7c504b2) to main (24c9c01).


What is this? | Workflow run | diff-shades documentation

Copy link
Collaborator

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thanks!

@JelleZijlstra JelleZijlstra merged commit 2623269 into psf:main Feb 2, 2024
46 checks passed
@hauntsaninja hauntsaninja deleted the ignore-non-black-pyproj branch February 2, 2024 05:51
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.

Black stops looking for config at first pyproject.toml file even if there's no black section in it
2 participants