Skip to content

Commit a2477ff

Browse files
Update code example in "Declaring decorators" (#14131)
- Added missing cast import - Changed revealed type Co-authored-by: Shantanu <[email protected]>
1 parent 05a3f7d commit a2477ff

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/source/generics.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ Before parameter specifications, here's how one might have annotated the decorat
635635

636636
.. code-block:: python
637637
638-
from typing import Callable, TypeVar
638+
from typing import Any, Callable, TypeVar, cast
639639
640640
F = TypeVar('F', bound=Callable[..., Any])
641641
@@ -650,8 +650,8 @@ and that would enable the following type checks:
650650

651651
.. code-block:: python
652652
653-
reveal_type(a) # str
654-
add_forty_two('x') # Type check error: incompatible type "str"; expected "int"
653+
reveal_type(a) # Revealed type is "builtins.int"
654+
add_forty_two('x') # Argument 1 to "add_forty_two" has incompatible type "str"; expected "int"
655655
656656
657657
Note that the ``wrapper()`` function is not type-checked. Wrapper

0 commit comments

Comments
 (0)