Skip to content

Commit

Permalink
support named arguments, sensibly
Browse files Browse the repository at this point in the history
  • Loading branch information
Technologicat committed Oct 5, 2018
1 parent 653b2d2 commit ddd9d75
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions macropy/core/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,16 @@ def get_macro_details(self, macro_tree):
- the tree containing the macro itself (it is *macro_tree*
itself as of now);
- arguments to the macro invocation;
- if a Call, named arguments to the macro invocation, as OrderedDict.
- named arguments to the macro invocation.
"""
kwargs = collections.OrderedDict() # keywords is a list; preserve order
if isinstance(macro_tree, ast.Call):
call_args = tuple(macro_tree.args)
for kw in macro_tree.keywords:
if kw.arg is not None:
kwargs[kw.arg] = kw.value
kwargs = tuple(macro_tree.keywords)
macro_tree = macro_tree.func
else:
call_args = ()
kwargs = ()
if isinstance(macro_tree, ast.Name):
return macro_tree.id, macro_tree, call_args, kwargs
else:
Expand Down

0 comments on commit ddd9d75

Please sign in to comment.