[issue46511] dataclasses: Allow typing.Annotated to wrap dataclasses-specific annotations

Gregory Beauregard report at bugs.python.org
Fri Feb 11 14:22:33 EST 2022


Gregory Beauregard <greg at greg.red> added the comment:

It occurred to be that we do need to add the __call__ to KW_ONLY, but for a different reason than this bpo:

If you call get_type_hints on a dataclass with a KW_ONLY parameter when PEP 563 is enabled, the entire call will fail if KW_ONLY isn't callable(). This can also happen if you stringize KW_ONLY without PEP 563. I made a bpo to suggest removing the callable() check entirely, but it's waiting discussion currently: https://bugs.python.org/issue46644

My feeling is you probably wanted to wait on making changes of this kind for the 5.11 PEP 563 et al decision to play out, but on the other hand I think the KW_ONLY (and similar __call__ method for InitVar this patch already adds) change would likely be backportable so we may want to make them anyway for that purpose. Do you have an opinion on this?

This patch might be backportable to mirror https://bugs.python.org/issue46491 but I don't have a strong opinion on that.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46511>
_______________________________________


More information about the Python-bugs-list mailing list