summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcpopa <devnull@localhost>2014-08-04 16:49:03 +0300
committercpopa <devnull@localhost>2014-08-04 16:49:03 +0300
commite6aa90ddaa21d048bc13c651d9468a81a6f54e1e (patch)
tree7a8662a919fe0b5d3f804ae8b345e506f92c3c5b
parent492a0afe6815a8d886e7f0ce0043576a7f3e8f48 (diff)
downloadastroid-e6aa90ddaa21d048bc13c651d9468a81a6f54e1e.tar.gz
namedtuple inference knows about '_fields' attribute.
-rw-r--r--ChangeLog2
-rw-r--r--brain/py2stdlib.py2
2 files changed, 4 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 2fff5b8..d056337 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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])