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
mypy_extensions.TypedDict is problematic for several reasons:
mypy_extensions.TypedDict is missing quite a few features that have been added to typing.TypedDict at runtime (and have been backported to typing_extensions.TypedDict).
I think the existence of both mypy_extensions.TypedDict and typing_extensions.TypedDict has the potential to be pretty confusing for users.
It's quite annoying and error-prone that at typeshed, we have to remember to keep typing._TypedDict, typing_extensions._TypedDict and mypy_extensions._TypedDict all in sync. Unfortunately, we can't put them all in _typeshed and have all three modules import _TypedDict from _typeshed, as the three classes all have slightly subtle differences. (E.g. mypy_extensions._TypedDict doesn't have the __required_keys__ and __optional_keys__ ClassVars that both typing._TypedDict and typing_extensions._TypedDict have.)
Mypy now maintains its own copy of the mypy-extensions stubs anyway, so its stubs for mypy_extensions are no longer automatically updated with each typeshed sync. That means that even if we update the stubs for mypy_extensions.TypedDict in typeshed (as we did in Improve __(r)or__ signatures for TypedDict classes typeshed#10565), those updates are no longer of any benefit to mypy users unless mypy maintainers remember to copy across the changes to their forked version of the mypy_extensions stubs.
I propose that we deprecate mypy_extensions.TypedDict, and steer people towards typing_extensions.TypedDict instead: it's up-to-date with the features on typing.TypedDict, it's much more comprehensively tested, and it has up-to-date stubs.
Activity
JelleZijlstra commentedon Aug 17, 2023
Agree, there's no need for mypy_extensions.TypedDict any more. As an implementation strategy, we can:
mypy_extensions.TypedDictclass is createdmypy_extensions.TypedDictis usedAlexWaygood commentedon Aug 17, 2023
I'm taking a look at the runtime side of things. One issue: it seems we'd really need
stacklevel=3if you're constructing aTypedDictclass like this:...But you'd need
stacklevel=2if you're constructing aTypedDictlike this:I'm not sure if there's a way to distinguish between the two, if we emit the
DeprecationWarningin_TypedDictMeta.__new__AlexWaygood commentedon Aug 17, 2023
Hmm, I think I have a solution