
Jan. 18, 2021
11:54 p.m.
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 <songofacandy@gmail.com>