[New-bugs-announce] [issue40185] Refactor typing.NamedTuple

Serhiy Storchaka report at bugs.python.org
Sat Apr 4 17:08:45 EDT 2020


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

typing.NamedTuple is used in two ways.

1. It is a callable which produces a new namedtuple type.
2. It can also be used as a base in the class statement for creating a new namedtuple type.

In both cases it is not a real class. You cannot create an instance of NamedTuple or a subclass of NamedTuple. But it is implemented as a class, and help() shows methods and data descriptors for it, which are useless.

The proposed PR implements NamedTuple like a function. Implementation of the __mro_entries__ method allows to use it as a base in the class statement.

----------
components: Library (Lib)
messages: 365783
nosy: gvanrossum, levkivskyi, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Refactor typing.NamedTuple
type: enhancement
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40185>
_______________________________________


More information about the New-bugs-announce mailing list