|
Is Example: from typing import is_typeddict, Generic, TypeVar, TypedDict
A = TypeVar("A", bound=TypedDict)
class Attributes(TypedDict, total=False):
title: str
class Resource(TypedDict, Generic[A]):
a: A
print(is_typeddict(Resource[Attributes]))
# False
# Would have expected True...Live demo: https://www.online-python.com/Pa6C0sWjIh Hope this is the right place to report this. |
Replies: 2 comments 3 replies
|
@srittau Since you have turned into a discussion, do you have an opinion on this? My impression is that this is a bug, although I understand that properly validating specializations to ensure they are still |
|
This is expected for the specialized form, rather than a validation failure of the
So these differ intentionally: from typing import get_origin, is_typeddict
assert is_typeddict(Resource)
assert not is_typeddict(Resource[Attributes])
specialized = Resource[Attributes]
assert get_origin(specialized) is Resource
assert is_typeddict(get_origin(specialized))If the goal is to recognize both an unspecialized The current docs are here: https://docs.python.org/3/library/typing.html#typing.is_typeddict |
FYI: I opened an issue in CPython’s issue tracker. The current behavior appears to be intentional and is unlikely to change.