#4411·black

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

Author: ppena-LiveDataCreated Jul 24, 2024Updated Sep 13, 2026
LabelsT: bugS: needs discussion

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.