diff options
author | cpopa <devnull@localhost> | 2014-08-04 16:49:03 +0300 |
---|---|---|
committer | cpopa <devnull@localhost> | 2014-08-04 16:49:03 +0300 |
commit | e6aa90ddaa21d048bc13c651d9468a81a6f54e1e (patch) | |
tree | 7a8662a919fe0b5d3f804ae8b345e506f92c3c5b | |
parent | 492a0afe6815a8d886e7f0ce0043576a7f3e8f48 (diff) | |
download | astroid-e6aa90ddaa21d048bc13c651d9468a81a6f54e1e.tar.gz |
namedtuple inference knows about '_fields' attribute.
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | brain/py2stdlib.py | 2 |
2 files changed, 4 insertions, 0 deletions
@@ -8,6 +8,8 @@ Change log for the astroid package (used to be astng) * Set the parent of vararg and kwarg nodes when inferring them. Closes issue #43. + * namedtuple inference knows about '_fields' attribute. + 2014-07-25 -- 1.2.0 * Function nodes can detect decorator call chain and see if they are diff --git a/brain/py2stdlib.py b/brain/py2stdlib.py index e75c3ed..65d9d41 100644 --- a/brain/py2stdlib.py +++ b/brain/py2stdlib.py @@ -258,6 +258,7 @@ def infer_named_tuple(node, context=None): context=context) fake = AstroidBuilder(MANAGER).string_build(''' class %(name)s(tuple): + _fields = %(fields)r def _asdict(self): return self.__dict__ @classmethod @@ -272,6 +273,7 @@ class %(name)s(tuple): class_node.locals['_asdict'] = fake.body[0].locals['_asdict'] class_node.locals['_make'] = fake.body[0].locals['_make'] class_node.locals['_replace'] = fake.body[0].locals['_replace'] + class_node.locals['_fields'] = fake.body[0].locals['_fields'] # we use UseInferenceDefault, we can't be a generator so return an iterator return iter([class_node]) |