[New-bugs-announce] [issue31006] typing.NamedTuple should add annotations to its constructor (__new__) parameters.

Antony Lee report at bugs.python.org
Mon Jul 24 05:07:47 EDT 2017


New submission from Antony Lee:

Currently, the fields, types and defaults used to define a typing.NamedTuple need to be retrieved from three different attributes: `_fields`, `_field_types`, and `_field_defaults` (the first two are combined in `__annotations__`, but that still misses the defaults).

However, there is a place where all this information can be naturally combined: in the Signature of the constructor (as returned by `inspect.signature(cls)`).  Currently, the Parameter objects in the signature have the information about the parameter names and defaults, but their annotation is not set.

Thus, I would like to propose setting the annotation of the Parameters in the Signature object as well.

----------
components: Library (Lib)
messages: 298937
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: typing.NamedTuple should add annotations to its constructor (__new__) parameters.
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31006>
_______________________________________


More information about the New-bugs-announce mailing list