-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Re-implement magic trailing comma handling #1612
Conversation
Primer will obviously fail due to expected formatting changes. We'll be dealing with the other failures here, looks like they're infrastructure failures. |
LOL, such a rookie mistake. Will fix momentarily. |
This looks great! Much clearer logic than before. I spot checked some of the primer changes and they look good too |
- when a trailing comma is specified in any bracket pair, that signals to Black that this bracket pair needs to be always exploded, e.g. presented as "one item per line"; - this causes some changes to previously formatted code that erroneously left trailing commas embedded into single-line expressions; - internally, Black needs to be able to identify trailing commas that it put itself compared to pre-existing trailing commas. We do this by using/abusing lib2to3's `was_checked` attribute. It's True for internally generated trailing commas and False for pre-existing ones (in fact, for all pre-existing leaves and nodes). Fixes #1288
411d8e9
to
f207e14
Compare
4038faf
to
c5f34c4
Compare
I'm curious on why the auto generated documentation files from the README are included with your "fix dealing with generated files in docs" commit. Is it a mistake or am I missing something? |
Those files were always committed. Look at the history of |
❤️ ❤️ ❤️ |
Ah that explains it, thanks! When I look back at the history, those files like |
Might make sense to add a |
Re-implement magic trailing comma handling:
when a trailing comma is specified in any bracket pair, that signals to Black that this bracket pair needs to be always exploded, e.g. presented as "one item per line";
this causes some changes to previously formatted code that erroneously left trailing commas embedded into single-line expressions;
internally, Black needs to be able to identify trailing commas that it put itself compared to pre-existing trailing commas. We do this by using/abusing lib2to3's
was_checked
attribute. It's True for internally generated trailing commas and False for pre-existing ones (in fact, for all pre-existing leaves and nodes).Fixes #1288
Thank you, Sentry, for sponsoring this effort.