summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-10-07 13:13:29 +0300
committerClaudiu Popa <pcmanticore@gmail.com>2015-10-07 13:13:29 +0300
commit97d85fd9851b2a82c0932f1e23af9307bff1879b (patch)
tree065f57d03d2ce9705495c98dcd6892aaad22d53e
parenta6775279b2006fb6f27a0fbb86a35262020e550f (diff)
downloadastroid-git-97d85fd9851b2a82c0932f1e23af9307bff1879b.tar.gz
Change the signature of the ArgumentInference class to accept directly the arguments and the keywords of a call site.
-rw-r--r--astroid/arguments.py14
-rw-r--r--astroid/protocols.py9
2 files changed, 13 insertions, 10 deletions
diff --git a/astroid/arguments.py b/astroid/arguments.py
index 2b5d5013..2642620a 100644
--- a/astroid/arguments.py
+++ b/astroid/arguments.py
@@ -26,18 +26,18 @@ import six
class ArgumentInference(object):
- """Class for understanding arguments passed to functions
+ """Class for understanding arguments passed into a call site
- It needs a call context, an object which has the arguments
- and the keyword arguments that were passed into a given call site.
- After that, in order to infer what an argument represents, call
+ It needs the arguments and the keyword arguments that were
+ passed into a given call site.
+ In order to infer what an argument represents, call
:meth:`infer_argument` with the corresponding function node
and the argument name.
"""
- def __init__(self, callcontext):
- self._args = self._unpack_args(callcontext.args)
- self._keywords = self._unpack_keywords(callcontext.keywords)
+ def __init__(self, args, keywords):
+ self._args = self._unpack_args(args)
+ self._keywords = self._unpack_keywords(keywords)
args = [arg for arg in self._args if arg is not util.YES]
keywords = {key: value for key, value in self._keywords.items()
if value is not util.YES}
diff --git a/astroid/protocols.py b/astroid/protocols.py
index 1a80dfa4..24a85fa4 100644
--- a/astroid/protocols.py
+++ b/astroid/protocols.py
@@ -282,7 +282,8 @@ def _arguments_infer_argname(self, name, context):
return
if context and context.callcontext:
- inferator = arguments.ArgumentInference(context.callcontext)
+ inferator = arguments.ArgumentInference(context.callcontext.args,
+ context.callcontext.keywords)
for value in inferator.infer_argument(self.parent, name, context):
yield value
return
@@ -315,8 +316,10 @@ def arguments_assigned_stmts(self, node, context, asspath=None):
callcontext = context.callcontext
context = contextmod.copy_context(context)
context.callcontext = None
- return arguments.ArgumentInference(callcontext).infer_argument(
- self.parent, node.name, context)
+ inferator = arguments.ArgumentInference(
+ callcontext.args,
+ callcontext.keywords)
+ return inferator.infer_argument(self.parent, node.name, context)
return _arguments_infer_argname(self, node.name, context)
nodes.Arguments.assigned_stmts = arguments_assigned_stmts