summaryrefslogtreecommitdiff
path: root/astroid
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2018-10-10 11:51:26 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2018-10-10 11:51:26 +0200
commit8151853e9525252b75ae560273a709cbed47ddc5 (patch)
treeff694d351a9c28a5901298706fc3358899133835 /astroid
parent30c190948febb0f36bd259be7c977c92a8cc386f (diff)
downloadastroid-git-8151853e9525252b75ae560273a709cbed47ddc5.tar.gz
Remove the restore_path() method
This was initially added in e642ba33ba1bdde04ac9f0c75a25dc40131c55e7 so astroid won't skip undesired inference branches. The method though doesn't seem to influence anything as the added test is now passing regardless if we restore the path or not. The correct approach would have been to clone the context instead. But given that the context is usually used for caching already inferenced objects, we don't necessarily need to clone it here, but rather in the low level inference, where we'd know that the inference path will diverge.
Diffstat (limited to 'astroid')
-rw-r--r--astroid/scoped_nodes.py47
1 files changed, 22 insertions, 25 deletions
diff --git a/astroid/scoped_nodes.py b/astroid/scoped_nodes.py
index 290ebc22..18ea06d3 100644
--- a/astroid/scoped_nodes.py
+++ b/astroid/scoped_nodes.py
@@ -2190,32 +2190,29 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG, node_classes.Statement
return
for stmt in self.bases:
- with context.restore_path():
- try:
- for baseobj in stmt.infer(context):
- if not isinstance(baseobj, ClassDef):
- if isinstance(baseobj, bases.Instance):
- baseobj = baseobj._proxied
- else:
- continue
- if not baseobj.hide:
- if baseobj in yielded:
+ try:
+ for baseobj in stmt.infer(context):
+ if not isinstance(baseobj, ClassDef):
+ if isinstance(baseobj, bases.Instance):
+ baseobj = baseobj._proxied
+ else:
+ continue
+ if not baseobj.hide:
+ if baseobj in yielded:
+ continue
+ yielded.add(baseobj)
+ yield baseobj
+ if recurs:
+ for grandpa in baseobj.ancestors(recurs=True, context=context):
+ if grandpa is self:
+ # This class is the ancestor of itself.
+ break
+ if grandpa in yielded:
continue
- yielded.add(baseobj)
- yield baseobj
- if recurs:
- for grandpa in baseobj.ancestors(
- recurs=True, context=context
- ):
- if grandpa is self:
- # This class is the ancestor of itself.
- break
- if grandpa in yielded:
- continue
- yielded.add(grandpa)
- yield grandpa
- except exceptions.InferenceError:
- continue
+ yielded.add(grandpa)
+ yield grandpa
+ except exceptions.InferenceError:
+ continue
def local_attr_ancestors(self, name, context=None):
"""Iterate over the parents that define the given name.