Here's a use case for runtime type annotations: dataclasses use
annotations to define fields. With the exception of ClassVar, the actual
type is ignored. There's code in dataclasses.py to deal with stringized
annotations, specifically just looking for ClassVar. I'd like to see
this special case go away, assuming 649 is accepted.
And while dataclasses itself doesn't care about the types, apparently
users do, and want to be able to call get_type_hints on the annotations.
Many people actually want dataclasses to call this for them, but I've
resisted. See https://bugs.python.org/issue36643
There are plenty of bugs around this issue, some of which have been
fixed. But there are also at least a couple that haven't been fixed, and
I'm not sure they will be. I'm hoping that 649 gets accepted and I don't
have to worry about the problem at all. Here's an example of an open bug
around get_type_hints with dataclasses: https://bugs.python.org/issue45524
Eric
On 11/29/2021 6:00 PM, Barry Warsaw wrote:
On Nov 26, 2021, at 01:13, Paul Moore <p.f.mo...@gmail.com> wrote:
I'd therefore interpret Barry's plea as being for *anyone* with a use
for annotations to provide their feedback (at least, anyone who
accepts that annotations are types), with particular emphasis on
people who want to use the types declared in annotations to affect
runtime behaviour, as that's the most under-represented group at the
moment (and it's not clear whether it's under-represented because
there aren't many such uses, or because the users aren't being heard
from).
Spot on.
-Barry
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/4522JDS2ZOYXXFGPVXRGJ67IB3YLCEFM/
Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/ENVEVQUEMEDKT2YUI2LQOBZDJC2YMNQ5/
Code of Conduct: http://python.org/psf/codeofconduct/