black icon indicating copy to clipboard operation
black copied to clipboard

global config not possible if project contains a `pyproject.toml`

Open ppena-LiveData opened this issue 1 year ago • 2 comments

Describe the bug

We have multiple Python Git projects, which each have their own pyproject.toml, but we don't want to have to copy and paste the same [tool.black] section in each of them and would prefer to be able to have it configured in our user's ~/.black global config file. Unfortunately, black.files.find_pyproject_toml() doesn't check if the project's pyproject.toml file has a [tool.black] section before returning it, so that causes it to never check to see if there's a ~/.black global config file.

To Reproduce

Have a Python Git project with a pyproject.toml file that does not have a [tool.black] section, and have a ~/.black global config file in your user's directory. The file in your user's directory will be ignored.

Expected behavior

If a project's pyproject.toml file does not have a [tool.black] section, then black should look for a user-level ~/.black global config file.

Additional context

NOTE: this is similar to Issue #2863, but this asks for the [tool.black] section-searching to continue and not stop at the project level.

ppena-LiveData avatar Jul 24 '24 14:07 ppena-LiveData

Wouldn't this just make projects not self-contained? What happens when multiple contributors try then to contribute to a code base and black looses all reproducibility because they all have different configurations in their personal machine.

I know it is a stretch but this comes across as "I really don't want to specify my dependencies in my project why wont pip just use the global installation?". Just that it is what it actually does without a .venv and it is a endless source of bugs.

Michallote avatar Oct 29 '24 04:10 Michallote

We're talking about config, not package installations. BTW, pip also provides global and local config locations, since some configurations should be shareable by all projects.

ppena-LiveData avatar Oct 29 '24 13:10 ppena-LiveData