summaryrefslogtreecommitdiff
path: root/astroid/context.py
diff options
context:
space:
mode:
authorBryce Guinta <bryce.paul.guinta@gmail.com>2018-06-20 21:59:47 -0600
committerBryce Guinta <bryce.guinta@protonmail.com>2018-07-05 23:17:06 -0600
commitaea774e9554877871045f7f5d0a2f6e063a7c756 (patch)
tree4da5ffea7c605082a54874fdb685256bd3bd4ca5 /astroid/context.py
parent904734c383be4a7e11c8ed16e130d0dff5f56526 (diff)
downloadastroid-git-aea774e9554877871045f7f5d0a2f6e063a7c756.tar.gz
Fix inference for nested calls
Add context_lookup to the context class as extra_context. Deliver the correct context with the correct boundnode for function argument nodes. Close #177
Diffstat (limited to 'astroid/context.py')
-rw-r--r--astroid/context.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/astroid/context.py b/astroid/context.py
index 75cab636..a6ca9b7c 100644
--- a/astroid/context.py
+++ b/astroid/context.py
@@ -18,7 +18,7 @@ class InferenceContext:
Account for already visited nodes to infinite stop infinite recursion
"""
- __slots__ = ('path', 'lookupname', 'callcontext', 'boundnode', 'inferred')
+ __slots__ = ('path', 'lookupname', 'callcontext', 'boundnode', 'inferred', 'extra_context')
def __init__(self, path=None, inferred=None):
self.path = path or set()
@@ -61,6 +61,13 @@ class InferenceContext:
Currently the key is ``(node, lookupname, callcontext, boundnode)``
and the value is tuple of the inferred results
"""
+ self.extra_context = {}
+ """
+ :type: dict(NodeNG, Context)
+
+ Context that needs to be passed down through call stacks
+ for call arguments
+ """
def push(self, node):
"""Push node into inference path
@@ -87,6 +94,7 @@ class InferenceContext:
clone = InferenceContext(copy.copy(self.path), inferred=self.inferred)
clone.callcontext = self.callcontext
clone.boundnode = self.boundnode
+ clone.extra_context = copy.copy(self.extra_context)
return clone
def cache_generator(self, key, generator):