summaryrefslogtreecommitdiff
path: root/astroid/context.py
diff options
context:
space:
mode:
authorhippo91 <guillaume.peillex@gmail.com>2021-01-24 11:09:11 +0100
committerGitHub <noreply@github.com>2021-01-24 11:09:11 +0100
commitabf9d0e4e63d1098436602804548d07a0909ece1 (patch)
tree847eaa424e84df2eab786e21f28e66722fced417 /astroid/context.py
parent7c7848b7670e57517eb2b42ee605d18b4259248f (diff)
parent7c614b397300514cc8a12421cc428463ca6a364f (diff)
downloadastroid-git-abf9d0e4e63d1098436602804548d07a0909ece1.tar.gz
Merge pull request #884 from hippo91/sum_and_multiply_clean
Sum and multiply clean
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