mirror of
https://github.com/python/cpython.git
synced 2025-08-08 02:48:55 +00:00
[3.12] gh-113255: Clarify docs for typing.reveal_type
(GH-113286) (#113323)
gh-113255: Clarify docs for `typing.reveal_type` (GH-113286)
(cherry picked from commit 11ee912327
)
Co-authored-by: Kir <note351@hotmail.com>
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
This commit is contained in:
parent
44101e9cd3
commit
b01caf1d9d
2 changed files with 15 additions and 16 deletions
|
@ -3280,7 +3280,7 @@ sys.modules[re.__name__] = re
|
|||
|
||||
|
||||
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::
|
||||
|
@ -3292,7 +3292,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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue