diff options
| author | Claudiu Popa <pcmanticore@gmail.com> | 2014-10-20 17:41:05 +0300 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2014-10-20 17:41:05 +0300 |
| commit | 2e2d04b4c270f31c1a9883e9ae41bb2d4cbca3fe (patch) | |
| tree | 0be6f15bf00f1a276418ca292cad029d53ebd35b /brain/py2stdlib.py | |
| parent | 1ed485519d63e3fa9cd87cf336f39445d3488396 (diff) | |
| parent | 3a090e2819c85abacae5dd244733408cb110e427 (diff) | |
| download | astroid-git-2e2d04b4c270f31c1a9883e9ae41bb2d4cbca3fe.tar.gz | |
Various speed improvements.
Patch by Alex Munroe.
Diffstat (limited to 'brain/py2stdlib.py')
| -rw-r--r-- | brain/py2stdlib.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/brain/py2stdlib.py b/brain/py2stdlib.py index d728071b..92c783b4 100644 --- a/brain/py2stdlib.py +++ b/brain/py2stdlib.py @@ -259,6 +259,14 @@ MODULE_TRANSFORMS['subprocess'] = subprocess_transform # namedtuple support ########################################################### +def looks_like_namedtuple(node): + func = node.func + if type(func) is nodes.Getattr: + return func.attrname == 'namedtuple' + if type(func) is nodes.Name: + return func.name == 'namedtuple' + return False + def infer_named_tuple(node, context=None): """Specific inference function for namedtuple CallFunc node""" class_node, name, attributes = infer_func_form(node, nodes.Tuple._proxied, @@ -336,7 +344,7 @@ def infer_enum_class(node, context=None): return node MANAGER.register_transform(nodes.CallFunc, inference_tip(infer_named_tuple), - AsStringRegexpPredicate('namedtuple', 'func')) + looks_like_namedtuple) MANAGER.register_transform(nodes.CallFunc, inference_tip(infer_enum), AsStringRegexpPredicate('Enum', 'func')) MANAGER.register_transform(nodes.Class, infer_enum_class) |
