summaryrefslogtreecommitdiff
path: root/astroid/protocols.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2016-02-01 11:53:36 +0000
committerClaudiu Popa <pcmanticore@gmail.com>2016-02-13 14:08:58 +0000
commit6d2529632bae545ff7564501cac14316d5ea9204 (patch)
treecfcb11c01f1ddd4806a24469687a1ebc18bd41f4 /astroid/protocols.py
parent18fa724c04c2393b134d57d4fe4cebe38472bad8 (diff)
downloadastroid-git-6d2529632bae545ff7564501cac14316d5ea9204.tar.gz
Changed the way how parameters are being built
The old way consisted in having the parameter names, their defaults and their annotations separated in different components of the Arguments node. We introduced a new Param node, which holds the name of a parameter, its default value and its annotation. If any of the last two values are missing, then that slot will be filled with a new node kind, Empty, which is used for specifying the lack of something (None could have been used instead, but that means having non-AST nodes in the Arguments node). We're also having support for positional only arguments, for the moment only in raw_building. Close #215
Diffstat (limited to 'astroid/protocols.py')
-rw-r--r--astroid/protocols.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/astroid/protocols.py b/astroid/protocols.py
index eada9764..7fdc6e29 100644
--- a/astroid/protocols.py
+++ b/astroid/protocols.py
@@ -304,6 +304,7 @@ def mulass_assigned_stmts(self, nodes, node=None, context=None, assign_path=None
@assigned_stmts.register(treeabc.AssignName)
@assigned_stmts.register(treeabc.AssignAttr)
+@assigned_stmts.register(treeabc.Parameter)
def assend_assigned_stmts(self, nodes, node=None, context=None, assign_path=None):
return self.parent.assigned_stmts(self, context=context)
@@ -311,7 +312,7 @@ def assend_assigned_stmts(self, nodes, node=None, context=None, assign_path=None
def _arguments_infer_argname(self, name, context, nodes):
# arguments information may be missing, in which case we can't do anything
# more
- if not (self.args or self.vararg or self.kwarg):
+ if not self.args and (not self.vararg and not self.kwarg):
yield util.Uninferable
return
# first argument of instance/class method
@@ -336,10 +337,10 @@ def _arguments_infer_argname(self, name, context, nodes):
return
# TODO: just provide the type here, no need to have an empty Dict.
- if name == self.vararg:
+ if self.vararg and name == self.vararg.name:
yield nodes.Tuple(parent=self)
return
- if name == self.kwarg:
+ if self.kwarg and name == self.kwarg.name:
yield nodes.Dict(parent=self)
return
# if there is a default value, yield it. And then yield Uninferable to reflect