From 715b6662e56b5885e762e1555110d71b17790819 Mon Sep 17 00:00:00 2001 From: Anthony Johnson Date: Fri, 7 Apr 2017 16:36:23 -0700 Subject: [PATCH] Fix Python argument parsing for Call nodes This previous was throwing exceptions in some cases where Attribute nodes were used instead of Name nodes. --- autoapi/mappers/python.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autoapi/mappers/python.py b/autoapi/mappers/python.py index cf5639f..ebfee4c 100644 --- a/autoapi/mappers/python.py +++ b/autoapi/mappers/python.py @@ -186,7 +186,10 @@ class PythonPythonMapper(PythonMapperBase): ast.Name: 'id', ast.Num: 'n', ast.Str: lambda obj: '"{0}"'.format(obj.s), - ast.Call: lambda obj: obj.func.id, + # Call function name can be an `Attribute` or `Name` node, make sure + # we're using the correct attribute for the id + ast.Call: lambda obj: (obj.func.id if isinstance(obj.func, ast.Name) + else obj.func.attr), # TODO these require traversal into the AST nodes. Add this for more # complete argument parsing, or handle with a custom AST traversal. ast.List: lambda _: 'list',