Python 3.5+typingfunction
typing.no_type_check
decorators and markers
A decorator that turns off type checking for a function or class (the type checker ignores its annotations).
Syntax
@typing.no_type_check
On a class it applies recursively, silencing checks on every method at once, whereas a # type: ignore comment suppresses just one line. It's a blunt all-or-nothing tool, mostly meaningful for dynamically generated code where annotations shouldn't be read as types.
Examples
from typing import no_type_check
@no_type_check
def f(x): return x
print(f(3)) # → 3
See also
Open in the full glossarydocs.python.orgReport an inaccuracy