ID EN
Typing

reveal_type

Python 3.11

Ask a static type checker to reveal the inferred type of an expression.

Syntax

PYTHON
typing.reveal_type(obj, /)

Examples

Example 1
PYTHON
x: int = 1
reveal_type(x)   Revealed type is "builtins.int"
Example 2
PYTHON
x = reveal_type(1)   prints "Runtime type is int"
print(x)   prints "1"

See Also

sys.stderr