diff options
author | hippo91 <guillaume.peillex@gmail.com> | 2021-01-23 18:11:10 +0100 |
---|---|---|
committer | hippo91 <guillaume.peillex@gmail.com> | 2021-01-23 18:11:10 +0100 |
commit | 7c614b397300514cc8a12421cc428463ca6a364f (patch) | |
tree | 847eaa424e84df2eab786e21f28e66722fced417 /astroid/context.py | |
parent | 7c7848b7670e57517eb2b42ee605d18b4259248f (diff) | |
parent | 1322e5d7790b7e3aa629a4e86e3b9f9b5846886b (diff) | |
download | astroid-git-sum_and_multiply.tar.gz |
Merge branch 'sum_and_multiply' of https://github.com/hippo91/astroidsum_and_multiply
Diffstat (limited to 'astroid/context.py')
-rw-r--r-- | astroid/context.py | 10 |
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 |