[issue33077] typing: Unexpected result with value of instance of class inherited from typing.NamedTuple

Ivan Levkivskyi report at bugs.python.org
Thu Mar 15 18:36:53 EDT 2018


Ivan Levkivskyi <levkivskyi at gmail.com> added the comment:

Yes, this is because subclassing `typing.NamedTuple` is not an actual subclassing, but is just a syntactic sugar for calling `collections.namedtuple`. A discussion about allowing subclassing/extending named tuples previously appeared in https://github.com/python/typing/issues/427 but was subsequently closed as wontfix. In short, the argument was that we should keep feature set and implementation of named tuples simple/minimalistic, and instead recommend dataclasses for all more complex use cases. Note however, that this decision was never added to the `typing.NamedTuple` documentation. I think it totally makes sense to clarify this in the docs.

----------

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


More information about the Python-bugs-list mailing list