> On 10 Aug 2021, at 13:05, Eric V. Smith <e...@trueblade.com> wrote: > > If 649 is accepted, there will be few places where stringified annotations > will be needed. For example, forward references that are defined before > __annotations__ is examined will not need to be specified as strings. From > the PEP: "Actually, annotations would become much easier to use, as they > would now also handle forward references.
In general, yes, agreed. However, a popular special case that you're intimately familiar with are class decorators. Since those are executed quite eagerly, you'll have to account for failing evaluation of forward references. Example: from dataclasses import dataclass @dataclass class C: a: A class A: ... In this case PEP 649 doesn't help. I don't see evaluation failures discussed explicitly in the PEP but I assume it would be a NameError. It would also be interesting to see if we can somehow make it handle annotations that refer to the class they're used in. Example: @dataclass class Node: parent: Node - Ł
signature.asc
Description: Message signed with OpenPGP
_______________________________________________ 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/FVJAUJ4TOYLAFJJS7UUPLFETXIBFBBEE/ Code of Conduct: http://python.org/psf/codeofconduct/