-
-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
pyproject.toml detection fails in subdirectories when the file has no [tool.black]
section since black 24.2
#2052
Labels
bug
Something isn't working
Comments
meliache
pushed a commit
to meliache/black
that referenced
this issue
Aug 2, 2024
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
1 task
meliache
pushed a commit
to meliache/black
that referenced
this issue
Aug 2, 2024
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
meliache
pushed a commit
to meliache/black
that referenced
this issue
Aug 2, 2024
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
meliache
pushed a commit
to meliache/black
that referenced
this issue
Aug 2, 2024
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
JelleZijlstra
pushed a commit
to psf/black
that referenced
this issue
Aug 2, 2024
….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 <Michael.Eliachevitch@blueyonder.com>
My work also ran into this issue recently. I just opened #2242 to address it. |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Describe the bug
Since black release v24.2 black ignores
pyproject.toml
files without a[tool.black]
section. The bug arises because datamodel-codegen uses black'sblack.find_project_root
here, but that now that ignores pyproject.toml files without a[tool.black]
section, even if there is a[tool.datamodel-codegen]
section, as defined here:At my job I'm working in a monorepo where the python package and the
pyproject.toml
are in a subdirectory, i.e. with the structure<git root>/<python root>/pyproject.toml>
. We useruff
to reformat all generated files, so we didn't have a black config in the pyproject.toml. I noticed that datamodel-codegen could not fild our pyproject.toml. It assumed the project root is the git root, since the pyproject.toml was ignored (see code snippet above).To Reproduce
Expected behavior
Recognize
pyproject.toml
if it's in subdirectory and has no[tool.black]
section, as long as it has[tool.datamodel-codegen]
section.Version:
The text was updated successfully, but these errors were encountered: