bpo-38834: enable runtime inspection of TypeDict classes#17214
bpo-38834: enable runtime inspection of TypeDict classes#17214ilevkivskyi merged 1 commit intopython:masterfrom Zac-HD:typdedict-runtime
Conversation
This patch enables downstream projects inspecting a TypedDict subclass at runtime to tell which keys are optional. This is essential for generating test data with Hypothesis or validating inputs with typeguard or pydantic.
|
@gvanrossum What do you think, can we include this in 3.8.1? Or should it just go to master (3.9) and |
I'd put in 3.9 (master) and in typing_extensions. |
|
OK, @Zac-HD could you please make a PR to https://github.com/python/typing adding this to |
Backport of python/cpython#17214 (BPO-38834)
This patch enables downstream projects inspecting a TypedDict subclass at runtime to tell which keys are optional. This is essential for generating test data with Hypothesis or validating inputs with typeguard or pydantic.
This patch enables downstream projects inspecting a TypedDict subclass at runtime to tell which keys are optional. This is essential for generating test data with Hypothesis or validating inputs with typeguard or pydantic.
|
@Zac-HD I don't think this was intended:
|
|
The bug is not really your fault though; It happens because |
|
Created https://bugs.python.org/issue42059. |
Backport of python/cpython#17214 (BPO-38834)
Backport of python/cpython#17214 (BPO-38834)
This patch enables downstream projects inspecting a TypedDict subclass at runtime to tell which keys are optional, which is essential for generating test data with Hypothesis or validating inputs with typeguard or pydantic.
More background on the typing-sig mailing list (cc @ilevkivskyi).
https://bugs.python.org/issue38834