summaryrefslogtreecommitdiff
path: root/protocols.py
diff options
context:
space:
mode:
authorEevee (Alex Munroe) <amunroe@yelp.com>2014-03-21 19:04:31 -0700
committerEevee (Alex Munroe) <amunroe@yelp.com>2014-07-01 17:33:00 -0700
commit2bf7e926b234bf8376a63f672380d2f1ae8eeb8d (patch)
tree9bf4dbeb167a4e12b94a551a1817fee8f927c6c7 /protocols.py
parenteb4cfdf7d5ab13616fda66c17ba3f822d7ef82ac (diff)
downloadastroid-git-2bf7e926b234bf8376a63f672380d2f1ae8eeb8d.tar.gz
Replace copy_context with some dynamic scoping.
Diffstat (limited to 'protocols.py')
-rw-r--r--protocols.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/protocols.py b/protocols.py
index e66b802c..616340c9 100644
--- a/protocols.py
+++ b/protocols.py
@@ -23,7 +23,7 @@ __doctype__ = "restructuredtext en"
from astroid.exceptions import InferenceError, NoDefault
from astroid.node_classes import unpack_infer
-from astroid.bases import copy_context, \
+from astroid.bases import InferenceContext, \
raise_if_nothing_infered, yes_if_nothing_infered, Instance, YES
from astroid.nodes import const_factory
from astroid import nodes
@@ -239,9 +239,11 @@ def _arguments_infer_argname(self, name, context):
# if there is a default value, yield it. And then yield YES to reflect
# we can't guess given argument value
try:
- context = copy_context(context)
- for infered in self.default_value(name).infer(context):
- yield infered
+ if context is None:
+ context = InferenceContext()
+ with context.scope(lookupname=None):
+ for infered in self.default_value(name).infer(context):
+ yield infered
yield YES
except NoDefault:
yield YES
@@ -251,11 +253,10 @@ def arguments_assigned_stmts(self, node, context, asspath=None):
if context.callcontext:
# reset call context/name
callcontext = context.callcontext
- context = copy_context(context)
- context.callcontext = None
- for infered in callcontext.infer_argument(self.parent, node.name, context):
- yield infered
- return
+ with context.scope(callcontext=None, lookupname=None):
+ for infered in callcontext.infer_argument(self.parent, node.name, context):
+ yield infered
+ return
for infered in _arguments_infer_argname(self, node.name, context):
yield infered
nodes.Arguments.assigned_stmts = arguments_assigned_stmts