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_checkedattribute. 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.