summaryrefslogtreecommitdiff
path: root/checkers/classes.py
diff options
context:
space:
mode:
Diffstat (limited to 'checkers/classes.py')
-rw-r--r--checkers/classes.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/checkers/classes.py b/checkers/classes.py
index 6dd5df0..f5e2783 100644
--- a/checkers/classes.py
+++ b/checkers/classes.py
@@ -458,6 +458,10 @@ a metaclass class method.'}
self._check_protected_attribute_access(node)
+ def visit_assattr(self, node):
+ if isinstance(node.ass_type(), astroid.AugAssign) and self.is_first_attr(node):
+ self._accessed[-1].setdefault(node.attrname, []).append(node)
+
@check_messages('protected-access')
def visit_assign(self, assign_node):
node = assign_node.targets[0]
@@ -540,6 +544,19 @@ a metaclass class method.'}
except astroid.NotFoundError:
pass
else:
+ # filter out augment assignment nodes
+ defstmts = [stmt for stmt in defstmts if stmt not in nodes]
+ if not defstmts:
+ # only augment assignment for this node, no-member should be
+ # triggered by the typecheck checker
+ continue
+ # filter defstmts to only pick the first one when there are
+ # several assignments in the same scope
+ scope = defstmts[0].scope()
+ defstmts = [stmt for i, stmt in enumerate(defstmts)
+ if i == 0 or stmt.scope() is not scope]
+ # if there are still more than one, don't attempt to be smarter
+ # than we can be
if len(defstmts) == 1:
defstmt = defstmts[0]
# check that if the node is accessed in the same method as