gh-113255: Clarify docs for typing.reveal_type (#113286)

Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
This commit is contained in:
Kir 2023-12-21 02:21:23 +09:00 committed by GitHub
parent de8a4e52a5
commit 11ee912327
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 16 deletions

View file

@ -3301,7 +3301,7 @@ class TextIO(IO[str]):
def reveal_type[T](obj: T, /) -> T:
"""Reveal the inferred type of a variable.
"""Ask a static type checker to reveal the inferred type of an expression.
When a static type checker encounters a call to ``reveal_type()``,
it will emit the inferred type of the argument::
@ -3313,7 +3313,7 @@ def reveal_type[T](obj: T, /) -> T:
will produce output similar to 'Revealed type is "builtins.int"'.
At runtime, the function prints the runtime type of the
argument and returns it unchanged.
argument and returns the argument unchanged.
"""
print(f"Runtime type is {type(obj).__name__!r}", file=sys.stderr)
return obj