Skip to content

Commit

Permalink
Move omit yield to end of generator
Browse files Browse the repository at this point in the history
Fix `omit` generator exiting early after seeing two consecutive non-empty bracket pairs before seeing a magic comma. This does cause a regression with `trailing_comma_optional_parens2` and it still does not fix lines with multiple magic commas.
  • Loading branch information
KindaOK committed Nov 16, 2022
1 parent 6079db6 commit 48042ee
Showing 1 changed file with 1 addition and 1 deletion.
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

0 comments on commit 48042ee

Please sign in to comment.