Skip to content

Commit c213db0

Browse files
[docs] update information about reveal type & locals in common_issues (#19059)
Previously it was impossible to have these in at runtime (more or less), but now you can just import one of them. --------- Co-authored-by: Shantanu <[email protected]>
1 parent 813b4d1 commit c213db0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

docs/source/common_issues.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -513,11 +513,15 @@ to see the types of all local variables at once. Example:
513513
# b: builtins.str
514514
.. note::
515515

516-
``reveal_type`` and ``reveal_locals`` are only understood by mypy and
517-
don't exist in Python. If you try to run your program, you'll have to
518-
remove any ``reveal_type`` and ``reveal_locals`` calls before you can
519-
run your code. Both are always available and you don't need to import
520-
them.
516+
``reveal_type`` and ``reveal_locals`` are handled specially by mypy during
517+
type checking, and don't have to be defined or imported.
518+
519+
However, if you want to run your code,
520+
you'll have to remove any ``reveal_type`` and ``reveal_locals``
521+
calls from your program or else Python will give you an error at runtime.
522+
523+
Alternatively, you can import ``reveal_type`` from ``typing_extensions``
524+
or ``typing`` (on Python 3.11 and newer)
521525

522526
.. _silencing-linters:
523527

0 commit comments

Comments
 (0)