Skip to content

Commit

Permalink
asfsf
Browse files Browse the repository at this point in the history
  • Loading branch information
mimre25 committed Feb 8, 2024
1 parent 7531009 commit 76e009b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions bugbear.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import re
import sys
import warnings
from collections import namedtuple
from collections import defaultdict, namedtuple
from contextlib import suppress
from functools import lru_cache, partial
from keyword import iskeyword
Expand Down Expand Up @@ -1620,17 +1620,18 @@ class B909Checker(ast.NodeVisitor):

def __init__(self, name: str):
self.name = name
self.mutations = []
self.mutations = defaultdict(list)
self._conditional_block = 0

def visit_Assign(self, node: ast.Assign):
for target in node.targets:
if isinstance(target, ast.Subscript) and _to_name_str(target.value):
self.mutations.append(node)
self.mutations[self._conditional_block].append(node)
self.generic_visit(node)

def visit_AugAssign(self, node: ast.AugAssign):
if _to_name_str(node.target) == self.name:
self.mutations.append(node)
self.mutations[self._conditional_block].append(node)
self.generic_visit(node)

def visit_Delete(self, node: ast.Delete):
Expand All @@ -1644,7 +1645,7 @@ def visit_Delete(self, node: ast.Delete):
self.generic_visit(target)

if name == self.name:
self.mutations.append(node)
self.mutations[self._conditional_block].append(node)

def visit_Call(self, node: ast.Call):
if isinstance(node.func, ast.Attribute):
Expand All @@ -1656,7 +1657,7 @@ def visit_Call(self, node: ast.Call):
function_object == self.name
and function_name in self.MUTATING_FUNCTIONS
):
self.mutations.append(node)
self.mutations[self._conditional_block].append(node)

self.generic_visit(node)

Expand Down

0 comments on commit 76e009b

Please sign in to comment.