-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Honour pyproject.toml also when it is not in the root folder of the project #236
Comments
@japsu We don't control how Option 1:You could pin
This way you can open Option 2:Another way to solve this is to make your project a multi-root project. In this mode all of your python configurations will sit in
|
I don't know exactly why but I see the same behavior as @japsu In the 2023-06-01 15:44:23.449 [info] /opt/conda/envs/abm/bin/python -m black -v --stdin-filename /workspaces/software/backends/src/app/main.py -
2023-06-01 15:44:23.454 [info] CWD formatter: /workspaces/software
2023-06-01 15:44:23.618 [info] Identified `/workspaces/software/backends` as project root containing a pyproject.toml.
Sources to be formatted: "-"
reformatted /workspaces/software/backends/src/app/main.py
All done! ✨ 🍰 ✨
1 file reformatted. If I run a similar command in a terminal inside VSCode I get different results: /opt/conda/envs/abm/bin/python -m black -v /workspaces/software/backends/src/app/main.py
Identified `/workspaces/software/backends` as project root containing a pyproject.toml.
Sources to be formatted: "src/app/main.py"
Using configuration from project root.
line_length: 120
/workspaces/software/backends/src/app/main.py already well formatted, good job.
All done! ✨ 🍰 ✨
1 file left unchanged. Both report |
@renan-abm There might be a behavior difference in black when using stdin.
If that behaves differently, when compared with:
Then you have an excellent repro and you should file this bug on black. Basically it is not honoring the |
You're right @karthiknadig that's an issue with |
FYI: I made a PR upstream with a potential fix to this |
Yesterday |
@renan-r-santos Thank you!!! |
For anyone running into this issue with bundled For now, install |
Consider a project layout in which you have
myproject/
(project root, opened in VS Code)backend/
(root of Python universe)pyproject.toml
with[tool.black]
sectionfrontend/
(root of Node.js universe)Now when editing Python files under
myproject/backend
, the[tool.black]
section inmyproject/backend/pyproject.toml
will not be honoured.If the
pyproject.toml
resides in the root foldermyproject/
, it is honoured.If the
myproject/backend
folder is opened in VS Code instead ofmyproject
, it is honoured.Please make the Black extension also honour the
pyproject.toml
file that is in a parent folder of the file being edited even if that folder is not the project root.The text was updated successfully, but these errors were encountered: