This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gousaiyang
Recipients BTaskaya, gousaiyang, gvanrossum, lys.nikolaou, pablogsal, serhiy.storchaka
Date 2021-04-09.20:01:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1617998491.22.0.531822600912.issue42737@roundup.psfhosted.org>
In-reply-to
Content
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).
History
Date User Action Args
2021-04-09 20:01:31gousaiyangsetrecipients: + gousaiyang, gvanrossum, serhiy.storchaka, lys.nikolaou, pablogsal, BTaskaya
2021-04-09 20:01:31gousaiyangsetmessageid: <1617998491.22.0.531822600912.issue42737@roundup.psfhosted.org>
2021-04-09 20:01:31gousaiyanglinkissue42737 messages
2021-04-09 20:01:31gousaiyangcreate