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

Fix internal magic commas not being force expanded #3377

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/black/linegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,6 @@ def generate_trailers_to_omit(line: Line, line_length: int) -> Iterator[Set[Leaf
omit.add(id(closing_bracket))
omit.update(inner_brackets)
inner_brackets.clear()
yield omit

if (
prev
Expand All @@ -1246,6 +1245,7 @@ def generate_trailers_to_omit(line: Line, line_length: int) -> Iterator[Set[Leaf
if leaf.value:
opening_bracket = leaf.opening_bracket
closing_bracket = leaf
yield omit


def run_transformer(
Expand Down
33 changes: 33 additions & 0 deletions tests/data/simple_cases/deep_trailing_commas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
assert foo(1, 2, 3,)[0] == {"bar": "baz"}

a = [1,][2]()
b = [1,][2](3)

[1, 2,]()(3, 4,)()(5, 6,)(0)(0)

# output


assert foo(
1,
2,
3,
)[0] == {"bar": "baz"}

a = [
1,
][2]()
b = [
1,
][2](3)

[
1,
2,
]()(
3,
4,
)()(
5,
6,
)(0)(0)