Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2019-04-03.13:07:30.022>labels= ['3.7', 'type-bug', 'library']
title='typing.NamedTuple does not support mixins'updated_at=<Date2021-02-09.09:57:06.552>user='https://bugs.python.org/rectalogic'
Subclassing typing.NamedTuple an inheriting from a mixin class does not work. It does work for collections.namedtuple, and can be worked around by modifying typing.NamedTupleMeta:
Hm, it looks like we can support this. I however don't think the proposed "patch" is the right way to fix it, since this makes the implementation with and without a mixin quite different.
Also I am not sure I will have time to work on this in the nearest month.
Generic NamedTuples are supported on 3.11+, and the decision has been taken to prohibit mixins in other situations. I don't think we'll be changing that now. Closing as completed.
Activity
rectalogic commented on Apr 3, 2019
Subclassing typing.NamedTuple an inheriting from a mixin class does not work. It does work for collections.namedtuple, and can be worked around by modifying typing.NamedTupleMeta:
ilevkivskyi commented on Apr 6, 2019
Hm, it looks like we can support this. I however don't think the proposed "patch" is the right way to fix it, since this makes the implementation with and without a mixin quite different.
Also I am not sure I will have time to work on this in the nearest month.
serhiy-storchaka commented on Apr 4, 2020
New changeset a94e627 by Serhiy Storchaka in branch 'master':
bpo-36517: Raise error on multiple inheritance with NamedTuple (GH-19363)
a94e627
bentheiii commented on Feb 9, 2021
The patch PR blocks out a useful idiom: generic Nametuple
I put forward that, at the least, NamedTuple should accept do-nothing bases like Generic.
AlexWaygood commented on Apr 10, 2023
Generic NamedTuples are supported on 3.11+, and the decision has been taken to prohibit mixins in other situations. I don't think we'll be changing that now. Closing as completed.