Skip to content

Commit

Permalink
Merge pull request #470 from asottile/fix_metaclass_type_without_extr…
Browse files Browse the repository at this point in the history
…a_newline

fix __metaclass__ = type replacement without extra newline
  • Loading branch information
asottile committed Jun 11, 2021
2 parents 63701d1 + c14826f commit cf78116
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyupgrade/_plugins/metaclass_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

def _remove_metaclass_type(i: int, tokens: List[Token]) -> None:
j = find_end(tokens, i)
del tokens[i:j + 1]
del tokens[i:j]


@register(ast.Assign)
Expand Down
6 changes: 6 additions & 0 deletions tests/features/metaclass_type_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ def test_metaclass_type_assignment_noop(s):
'',
id='module-scope assignment across newline',
),
pytest.param(
'__metaclass__ = type\n'
'a = 1\n',
'a = 1\n',
id='replace with code after it',
),
),
)
def test_fix_metaclass_type_assignment(s, expected):
Expand Down

0 comments on commit cf78116

Please sign in to comment.