Allow TypedDict to inherit from Generics #89026
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
assignee = None closed_at = None created_at = <Date 2021-08-07.19:04:47.278> labels = ['type-feature', 'library', '3.11'] title = 'Allow TypedDict to inherit from Generics' updated_at = <Date 2022-03-07.00:48:26.270> user = 'https://github.com/sransara'
activity = <Date 2022-03-07.00:48:26.270> actor = 'rhettinger' assignee = 'none' closed = False closed_date = None closer = None components = ['Library (Lib)'] creation = <Date 2021-08-07.19:04:47.278> creator = 'sransara' dependencies =  files =  hgrepos =  issue_num = 44863 keywords = ['patch'] message_count = 8.0 messages = ['399201', '399579', '401077', '401087', '401134', '401138', '412439', '414631'] nosy_count = 12.0 nosy_names = ['gvanrossum', 'rhettinger', 'python-dev', 'serhiy.storchaka', 'graingert', 'JelleZijlstra', 'sobolevn', 'kj', 'AlexWaygood', 'sransara', 'cdce8p', 'toburger'] pr_nums = ['27663'] priority = 'normal' resolution = None stage = 'patch review' status = 'open' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue44863' versions = ['Python 3.11']
The text was updated successfully, but these errors were encountered:
TypedDict PEP-589 says:
So the current implementation has:
This restricts the user from defining generic TypedDicts in the natural class based syntax:
Although PEP-589 doesn't explicitly state generic support, I believe it is complete in covering the specification even if generics were involved (at least for the class based syntax).
I have tried putting together a PEP from guidance of typing-sig <https://github.com/sransara/py-generic-typeddict/blob/master/pep-9999.rst\>. There is not much new contributions by that draft, except for specifying the alternative syntax and being more explicit about Generics.
So I'm wondering if it would be possible to relax the constraint: TypedDict inheritance to include Generic. In my point of view
Updating an existing (standards track) PEP significantly is not
On Sun, Sep 5, 2021 at 01:24 Ken Jin <firstname.lastname@example.org> wrote:
My initial intention to create this ticket was to explore the idea that if we could side step from creating a PEP or updating PEP-589.
IMO only contribution from a new PEP will be:
I believe PEP-589 is complete in covering all semantic details even with Generics. Even structural subtyping because it says: "Value types behave invariantly, since TypedDict objects are mutable."
My understanding was that during initial implementation this was not done for the sake of implementation simplicity (days before PEP-560).
All that said, a new PEP would be a good way to notify the type checkers of this capability.
Is there a better place to have this conversation?
there's a thread on typing-sig for this now: https://email@example.com/thread/I7P3ER2NH7SENVMIXK74U6L4Z5JDLQGZ/#I7P3ER2NH7SENVMIXK74U6L4Z5JDLQGZ