Skip to content

Commit

Permalink
fix(b038): Add dict.popitem() to list of mutating functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mimre25 committed Jan 16, 2024
1 parent 6ffdefb commit a0d6575
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions bugbear.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,7 @@ class B038Checker(ast.NodeVisitor):
"extend",
"insert",
"pop",
"popitem",
)

def __init__(self, name: str):
Expand Down
2 changes: 2 additions & 0 deletions tests/b038.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,5 @@ def __init__(self, ls):
for mydict in mydicts:
if mydicts.get('a', ''):
print(mydict['foo']) # should not error
mydicts.popitem() # should error

1 change: 1 addition & 0 deletions tests/test_bugbear.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ def test_b038(self):
B038(61, 8),
B038(62, 8),
B038(63, 8),
B038(74, 8),
]
self.assertEqual(errors, self.errors(*expected))

Expand Down

0 comments on commit a0d6575

Please sign in to comment.