On 2/14/21 1:34 PM, Joseph Perez wrote:
I completely agree with Paul Bryan as I think PEP 593 `Annotated` should be used for this case.
The `dataclasses` module use regex parsing to solve this issue, but
Annotated[] appears intended for user code to add its own annotations that do not collide with any existing type hints used by type checkers. So creating a special interpretation of something inside an Annotated[] would be counter to the spirit. Also `Annotated[..., Required]` is unnecessarily longer than `Required[...]`. Why type more? On 2/14/21 1:34 PM, Joseph Perez wrote: this solution can be debated. I've thought about a solution that slightly overtake the scope of this PEP: typing module could provide an `_eval_annotations` function [...] This is getting a bit off-topic, but the `typing.get_type_hints()` function already evaluates ForwardRef() values, although it has some limitations and restrictions on practical usage. Getting something like eval_annotations() to work in more cases is non-trivial, and best put on a new thread. On 2/11/21 8:50 PM, David Foster wrote:
As my next step I'll plan on RST-izing this PEP and submitting it as a PR to the PEPs repository.
In other news, I'm planning to get the PEP submitted via PR this weekend. -- David Foster | Seattle, WA, USA Contributor to TypedDict support for mypy