]> git.madduck.net Git - etc/vim.git/commit

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Add parens around implicit string concatenations where it increases readability ...
authorYilei "Dolee" Yang <yileiyang@google.com>
Wed, 31 Aug 2022 02:52:00 +0000 (19:52 -0700)
committerGitHub <noreply@github.com>
Wed, 31 Aug 2022 02:52:00 +0000 (22:52 -0400)
commitba618a307a30a119b4fafe526ebf7d5f092ba981
tree7cdc511ea21e5946cd5626f734363dbfb4a74376
parentc0cc19b5b3371842d696875897bebefebd5e1596
Add parens around implicit string concatenations where it increases readability (#3162)

Adds parentheses around implicit string concatenations when it's inside
a list, set, or tuple. Except when it's only element and there's no trailing
comma.

Looking at the order of the transformers here, we need to "wrap in
parens" before string_split runs. So my solution is to introduce a
"collaboration" between StringSplitter and StringParenWrapper where the
splitter "skips" the split until the wrapper adds the parens (and then
the line after the paren is split by StringSplitter) in another pass.

I have also considered an alternative approach, where I tried to add a
different "string paren wrapper" class, and it runs before string_split.
Then I found out it requires a different do_transform implementation
than StringParenWrapper.do_transform, since the later assumes it runs
after the delimiter_split transform. So I stopped researching that
route.

Originally function calls were also included in this change, but given
missing commas should usually result in a runtime error and the scary
amount of changes this cause on downstream code, they were removed in
later revisions.
CHANGES.md
src/black/trans.py
tests/data/preview/comments7.py
tests/data/preview/long_strings.py
tests/data/preview/long_strings__regression.py
tests/test_black.py