Skip to content
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

No configuration used for paths after the first #4461

Open
tmct opened this issue Sep 18, 2024 · 0 comments
Open

No configuration used for paths after the first #4461

tmct opened this issue Sep 18, 2024 · 0 comments
Labels
T: bug Something isn't working

Comments

@tmct
Copy link

tmct commented Sep 18, 2024

Describe the bug

Black configurations are seemingly not taken into account for any paths after the first one passed to CLI - I'm seeing this in particular for "line-length" but have no reason to expect the behaviour is specifically related to that option.

Specifically this prevents me from running black on multiple projects in one command. Perhaps this is by design.

To Reproduce

Black version

black, 24.8.0 (compiled: yes)
Python (CPython) 3.10.10

Project setup

# repro/proj1/hi.py
print("hi")
# repro/proj1/pyproject.toml
[project]
name = "proj1"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = []

[tool.black]
line-length = 120
# repro/proj2/hello.py
import os


def main():
    return "abcdefghijk" if os.getcwd() is not None else "aeheahaehaeh;kaehbnmieasolngoaeinaeghaehgoiaen"


if __name__ == "__main__":
    main()
# repro/proj2/pyproject.toml
[project]
name = "proj2"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = []

[tool.black]
line-length = 120

Actual behaviour

(running commands from inside proj1)

$ black --check --diff . 
All done! ✨ 🍰 ✨
1 file would be left unchanged.
$ black --check --diff ../proj2
All done! ✨ 🍰 ✨
1 file would be left unchanged.
$ black --check --diff . ../proj2
--- /home/tom/code/repro/proj2/hello.py  2024-09-18 13:23:06.381794+00:00
+++ /home/tom/code/repro/proj2/hello.py  2024-09-18 13:44:24.114345+00:00
@@ -1,9 +1,13 @@
 import os
 
 
 def main():
-    return "abcdefghijk" if os.getcwd() is not None else "aeheahaehaeh;kaehbnmieasolngoaeinaeghaehgoiaen"
+    return (
+        "abcdefghijk"
+        if os.getcwd() is not None
+        else "aeheahaehaeh;kaehbnmieasolngoaeinaeghaehgoiaen"
+    )
 
 
 if __name__ == "__main__":
     main()
would reformat /home/tom/code/repro/proj2/hello.py

Oh no! 💥 💔 💥
1 file would be reformatted, 1 file would be left unchanged.

Expected behavior

Either one of the configurations would be taken into account, and I would be able to check both folders at once. (I don't mind which in my use case - these particular projects have identical tooling configurations.)

Environment

  • Black's version: 24.8.0
  • OS and Python version: [Ubuntu 20.04/Python (CPython) 3.10.10]

Thanks

@tmct tmct added the T: bug Something isn't working label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant