26 August 2025, 13:18 UTC
Variations on 'if TYPE_CHECKING'
Suggested by mypy documentation:
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import …
Works in mypy, pyright, pyrefly. Found in setuptool_scm generated __version__.py
:
TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import …
Works in mypy, pyright, pyrefly. Best variant for CircuitPython?
def const(x): return x
TYPE_CHECKING = const(0)
if TYPE_CHECKING:
from typing import …
Works in mypy only. Does not work in pyright, pyrefly:
if False:
from typing import …
All older entries
Website Copyright © 2004-2024 Jeff Epler