summaryrefslogtreecommitdiff
path: root/astroid/context.py
diff options
context:
space:
mode:
Diffstat (limited to 'astroid/context.py')
-rw-r--r--astroid/context.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/astroid/context.py b/astroid/context.py
index f1e06974..4bda945f 100644
--- a/astroid/context.py
+++ b/astroid/context.py
@@ -29,8 +29,10 @@ class InferenceContext:
"extra_context",
)
+ maximum_path_visit = 3
+
def __init__(self, path=None, inferred=None):
- self.path = path or set()
+ self.path = path or dict()
"""
:type: set(tuple(NodeNG, optional(str)))
@@ -87,10 +89,10 @@ class InferenceContext:
Allows one to see if the given node has already
been looked at for this inference context"""
name = self.lookupname
- if (node, name) in self.path:
+ if self.path.get((node, name), 0) >= self.maximum_path_visit:
return True
- self.path.add((node, name))
+ self.path[(node, name)] = self.path.setdefault((node, name), 0) + 1
return False
def clone(self):
@@ -108,7 +110,7 @@ class InferenceContext:
@contextlib.contextmanager
def restore_path(self):
- path = set(self.path)
+ path = dict(self.path)
yield
self.path = path