Skip to content

Commit 9ccf279

Browse files
meliacheMichael Eliachevitch
and
Michael Eliachevitch
authored
Document find_project_root ignoring pyproject.toml without [tool.black] (#4425)
Extend the docstring of black's `find_project_root` to mention that it ignores `pyproject.toml` files without a `[tool.black]` section. This is relevant because that function is also used by other python packages that use black. I found that e.g. datamodel-code-generator [1] uses that function and that there the ignoring of the pyproject.toml files lead to a degradation [2]. I think in that case it would be better to not use black's function for finding the pyproject.toml, but in any case this behavior should be documented. 1: https://github.com/koxudaxi/datamodel-code-generator 2: koxudaxi/datamodel-code-generator#2052 Co-authored-by: Michael Eliachevitch <[email protected]>
1 parent 14b6e61 commit 9ccf279

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/black/files.py

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ def find_project_root(
5959
) -> Tuple[Path, str]:
6060
"""Return a directory containing .git, .hg, or pyproject.toml.
6161
62+
pyproject.toml files are only considered if they contain a [tool.black]
63+
section and are ignored otherwise.
64+
6265
That directory will be a common parent of all files and directories
6366
passed in `srcs`.
6467

0 commit comments

Comments
 (0)