Skip to content

Commit

Permalink
Merge pull request #727 from asottile/empty-set-literal-newline
Browse files Browse the repository at this point in the history
rewrite set((\n))
  • Loading branch information
asottile authored Oct 6, 2022
2 parents 286156f + aa9d965 commit 1eef83a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
3 changes: 0 additions & 3 deletions pyupgrade/_plugins/set_literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ def _fix_set_empty_literal(i: int, tokens: list[Token]) -> None:
brace_stack.pop()
elif token in BRACES:
brace_stack.append(token)
elif '\n' in token:
# Contains a newline, could cause a SyntaxError, bail
return
j += 1

# Remove the inner tokens
Expand Down
4 changes: 1 addition & 3 deletions tests/features/set_literals_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
(
# Don't touch empty set literals
'set()',
# Don't touch set(empty literal) with newlines in them (may create
# syntax errors)
'set((\n))',
# Don't touch weird looking function calls -- use autopep8 or such
# first
'set (())', 'set ((1, 2))',
Expand Down Expand Up @@ -92,6 +89,7 @@ def test_fix_sets_noop(s):
' 99, 100,\n'
'}\n',
),
pytest.param('set((\n))', 'set()', id='empty literal with newline'),
),
)
def test_sets(s, expected):
Expand Down

0 comments on commit 1eef83a

Please sign in to comment.