ID EN
Typing

TYPE_CHECKING

Python 3.11

A special constant that is assumed to be True by 3rd party static type checkers. It is False at runtime.

Syntax

PYTHON
typing.TYPE_CHECKING

Examples

Example 1
PYTHON
if TYPE_CHECKING:
    import expensive_mod

def fun(arg: 'expensive_mod.SomeType') -> None:
    local_var: expensive_mod.AnotherType = other_fun()