Skip to content

Commit

Permalink
refactor(b038): Cleanup unused code in B038Checker (#448)
Browse files Browse the repository at this point in the history
The unused code would introduce a bug when used, thus I believe it's
better to remove it.
  • Loading branch information
mimre25 authored Jan 15, 2024
1 parent 7c823af commit 9c100b6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
5 changes: 0 additions & 5 deletions bugbear.py
Original file line number Diff line number Diff line change
Expand Up @@ -1623,11 +1623,6 @@ def visit_Call(self, node: ast.Call):

self.generic_visit(node)

def visit_Name(self, node: ast.Name):
if isinstance(node.ctx, ast.Del):
self.mutations.append(node)
self.generic_visit(node)

def visit(self, node):
"""Like super-visit but supports iteration over lists."""
if not isinstance(node, list):
Expand Down
1 change: 1 addition & 0 deletions tests/b038.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
print(elem)
if elem % 2 == 0:
some_other_list.remove(elem) # should not error
del some_other_list


some_list = [1, 2, 3]
Expand Down
6 changes: 3 additions & 3 deletions tests/test_bugbear.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,10 +976,10 @@ def test_b038(self):
print(errors)
expected = [
B038(11, 8),
B038(25, 8),
B038(26, 8),
B038(40, 8),
B038(46, 8),
B038(27, 8),
B038(41, 8),
B038(47, 8),
]
self.assertEqual(errors, self.errors(*expected))

Expand Down

0 comments on commit 9c100b6

Please sign in to comment.