diff options
| author | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-08-08 23:46:08 +0300 |
|---|---|---|
| committer | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-08-08 23:46:08 +0300 |
| commit | 24e5e1278c3e98c0cb1430cd04a3259a44a379bd (patch) | |
| tree | 318c9a64d8481c9df981ee568a671be21b865191 /astroid/as_string.py | |
| parent | 12cfa3c7d6826e71ea4b35d90ad516d6bf247a29 (diff) | |
| download | astroid-git-24e5e1278c3e98c0cb1430cd04a3259a44a379bd.tar.gz | |
Add CallFunc.keywords, instead of putting together args and kwargs in CallFunc.args
This patch improves the similarity with the Python's AST. Until now,
CallFunc.args contained both the positional arguments and the keyword arguments,
which was misleading and always it was required to filter out keywords when working
with arguments.
Diffstat (limited to 'astroid/as_string.py')
| -rw-r--r-- | astroid/as_string.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/astroid/as_string.py b/astroid/as_string.py index 01eb7185..e8fd440d 100644 --- a/astroid/as_string.py +++ b/astroid/as_string.py @@ -137,8 +137,14 @@ class AsStringVisitor(object): """return an astroid.CallFunc node as string""" expr_str = node.func.accept(self) args = [arg.accept(self) for arg in node.args] + if node.keywords: + keywords = [kwarg.accept(self) for kwarg in node.keywords] + else: + keywords = [] + if node.starargs: args.append('*' + node.starargs.accept(self)) + args.extend(keywords) if node.kwargs: args.append('**' + node.kwargs.accept(self)) return '%s(%s)' % (expr_str, ', '.join(args)) |
