@@ -2581,33 +2581,32 @@ Functions and decorators
25812581
25822582.. function :: reveal_type(obj, /)
25832583
2584- Reveal the inferred static type of an expression.
2584+ Ask a static type checker to reveal the inferred type of an expression.
25852585
25862586 When a static type checker encounters a call to this function,
2587- it emits a diagnostic with the type of the argument. For example::
2587+ it emits a diagnostic with the inferred type of the argument. For example::
25882588
25892589 x: int = 1
25902590 reveal_type(x) # Revealed type is "builtins.int"
25912591
25922592 This can be useful when you want to debug how your type checker
25932593 handles a particular piece of code.
25942594
2595- The function returns its argument unchanged, which allows using
2596- it within an expression::
2595+ At runtime, this function prints the runtime type of its argument to
2596+ :data: `sys.stderr ` and returns the argument unchanged (allowing the call to
2597+ be used within an expression)::
25972598
2598- x = reveal_type(1) # Revealed type is "builtins.int"
2599+ x = reveal_type(1) # prints "Runtime type is int"
2600+ print(x) # prints "1"
2601+
2602+ Note that the runtime type may be different from (more or less specific
2603+ than) the type statically inferred by a type checker.
25992604
26002605 Most type checkers support ``reveal_type() `` anywhere, even if the
26012606 name is not imported from ``typing ``. Importing the name from
2602- ``typing `` allows your code to run without runtime errors and
2607+ ``typing ``, however, allows your code to run without runtime errors and
26032608 communicates intent more clearly.
26042609
2605- At runtime, this function prints the runtime type of its argument to stderr
2606- and returns it unchanged::
2607-
2608- x = reveal_type(1) # prints "Runtime type is int"
2609- print(x) # prints "1"
2610-
26112610 .. versionadded :: 3.11
26122611
26132612.. decorator :: dataclass_transform(*, eq_default=True, order_default=False, \
0 commit comments