Hi, all.
I want to write type hints without worrying about runtime overhead.
Current best practice is:
```
from __future__ import annotations
import typing
if typing.TYPE_CHECKING:
import xxx # modules used only in type hints.
```
But it would be nice if I can avoid importing even "typing" module.
How about adding TYPE_CHECKING builtin that is False?
```
from __future__ import annotations
if TYPE_CHECKING:
from typing import Any, Optional
# We can use Any, Optional, etc here.
```
I wonder if we can make TYPE_CHECKING constant like True, False, and None.
But it will break existing `from typing import TYPE_CHECKING` codes.
Regards,
--
Inada Naoki <[email protected]>
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/LS2UZYWX3VHNIMKBGLYEE75N4E7D6CEE/
Code of Conduct: http://python.org/psf/codeofconduct/