Skip to content

Commit

Permalink
Document find_project_root ignoring pyproject.toml w/o tool.black
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Michael Eliachevitch authored and meliache committed Aug 2, 2024
1 parent 7fa1faf commit 637b919
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
<!-- Major changes to documentation and policies. Small docs changes
don't need a changelog entry. -->

- Document the ignoring of `pyproject.toml` files without a `tool.black` section in
`black.find_project_root`, a behaviour introduced in 24.0.2.

## 24.4.2

This is a bugfix release to fix two regressions in the new f-string parser introduced in
Expand Down
3 changes: 3 additions & 0 deletions src/black/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def find_project_root(
) -> Tuple[Path, str]:
"""Return a directory containing .git, .hg, or pyproject.toml.
pyproject.toml files are only considered if they contain a [tool.black]
section and are ignored otherwise.
That directory will be a common parent of all files and directories
passed in `srcs`.
Expand Down

0 comments on commit 637b919

Please sign in to comment.