@@ -2604,33 +2604,32 @@ Functions and decorators
26042604
26052605.. function :: reveal_type(obj, /)
26062606
2607- Reveal the inferred static type of an expression.
2607+ Ask a static type checker to reveal the inferred type of an expression.
26082608
26092609 When a static type checker encounters a call to this function,
2610- it emits a diagnostic with the type of the argument. For example::
2610+ it emits a diagnostic with the inferred type of the argument. For example::
26112611
26122612 x: int = 1
26132613 reveal_type(x) # Revealed type is "builtins.int"
26142614
26152615 This can be useful when you want to debug how your type checker
26162616 handles a particular piece of code.
26172617
2618- The function returns its argument unchanged, which allows using
2619- it within an expression::
2618+ At runtime, this function prints the runtime type of its argument to
2619+ :data: `sys.stderr ` and returns the argument unchanged (allowing the call to
2620+ be used within an expression)::
26202621
2621- x = reveal_type(1) # Revealed type is "builtins.int"
2622+ x = reveal_type(1) # prints "Runtime type is int"
2623+ print(x) # prints "1"
2624+
2625+ Note that the runtime type may be different from (more or less specific
2626+ than) the type statically inferred by a type checker.
26222627
26232628 Most type checkers support ``reveal_type() `` anywhere, even if the
26242629 name is not imported from ``typing ``. Importing the name from
2625- ``typing `` allows your code to run without runtime errors and
2630+ ``typing ``, however, allows your code to run without runtime errors and
26262631 communicates intent more clearly.
26272632
2628- At runtime, this function prints the runtime type of its argument to stderr
2629- and returns it unchanged::
2630-
2631- x = reveal_type(1) # prints "Runtime type is int"
2632- print(x) # prints "1"
2633-
26342633 .. versionadded :: 3.11
26352634
26362635.. decorator :: dataclass_transform(*, eq_default=True, order_default=False, \
0 commit comments