Saiyang Gou <[email protected]> added the comment:
I think we can just skip evaluating annotations for complex targets when in
module or class scope (they are not stored anyway). The point of PEP 563 is to
suppress any evaluation of annotations (regardless of position) at definition
time, while type checkers can still analyze them as usual.
This is the current behavior (ever since 3.7, with `from __future__ import
annotations`):
Python 3.10.0a7 (default, Apr 6 2021, 17:59:12) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> x = 1
>>> x.y: print('evaluated in module')
evaluated in module
>>> class A:
... u = 2
... u.v: print('evaluated in class')
...
evaluated in class
And I think they should become no-ops at run-time (as if the annotations were
wrapped in string form).
----------
nosy: +gousaiyang
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue42737>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com