diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2020-01-05 13:35:28 +0100 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2020-01-05 13:37:53 +0100 |
commit | 631539e8ca8cbdb73b1c8655214de10bdd51e466 (patch) | |
tree | 3c3a6d91032e961e12c58e6c5f4dff2d8850f512 /astroid/inference.py | |
parent | dd8bcd3f640f947d91d8179dc98e3ccb4613f190 (diff) | |
download | astroid-git-631539e8ca8cbdb73b1c8655214de10bdd51e466.tar.gz |
Use the parent of the node when inferring aug assign nodes instead of the statement
In 19b5af02304e3339fdd2a26cfafc337960eeebce we added a check for `AugAssign` nodes
when inferring `Assign` values. Unfortunately the `infer_assign` function was also
used by `infer_assignname`, which meant that when trying to infer an `AssignName` node,
we were inferring its value as the result of the `AugAssign` inference, leading
to spurious false positives.
Close PyCQA/pylint#2911
Close PyCQA/pylint#3214
Diffstat (limited to 'astroid/inference.py')
-rw-r--r-- | astroid/inference.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/astroid/inference.py b/astroid/inference.py index a563287d..9c613cfe 100644 --- a/astroid/inference.py +++ b/astroid/inference.py @@ -837,9 +837,8 @@ def infer_assign(self, context=None): """infer a AssignName/AssignAttr: need to inspect the RHS part of the assign node """ - stmt = self.statement() - if isinstance(stmt, nodes.AugAssign): - return stmt.infer(context) + if isinstance(self.parent, nodes.AugAssign): + return self.parent.infer(context) stmts = list(self.assigned_stmts(context=context)) return bases._infer_stmts(stmts, context) |