-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Black producing very different output for the same file. #3037
Comments
Some additional info:
Same problem that one branch has one formatting and one branch has the other with the same configuration. |
Black doesn't promise to format all equivalent code the exact same way. Black's behaviour does depend on the previous formatting (although Black tries to avoid doing so). Magic trailing comma is an obvious example of where Black takes previous formatting into account, but there are others, often involving parentheses. |
It introduced those parens, I didn't write it that way but that probably happened with the magic parens. The fact that it. "sometimes" reformats things so that there is nothing deterministic about it means that diffs can get really painful (like last night). I think claims like this should come with a serious asterisk next to them:
Except when it doesn't..... |
I don't see an actionable issue here. #2135 already proposes removing the magic trailing comma by default. |
Describe the bug
Using black on 2 different branches of the same code (but with the same config files) I'm getting very different output from black
I have run
rm -rf ~/Library/Caches/black/*
in between the branch switches just to see if that was having any effect and it did not.We've seen this on another machine where his black formatted code was not the same as mine, but this is using one VENV on one machine with one REPO and 2 branches.
I thought it must be a configuration problem until I can check out the different version from branch B, and it doesn't reformat it which says that Black is perfectly happy with 2 different formats of the exact same file.
Expected behavior
black would always format the same code the same way.
Additional context
I've cut the repo down to 1 file with 2 branches and put a script in the README.md that reproduces this problem. requirements.txt contains 1 requirement (black)
https://github.com/boatcoder/black-issue
The text was updated successfully, but these errors were encountered: