You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 commentedon 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 commentedon 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 commentedon 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 commentedon 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 commentedon 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.