Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update code example in "Declaring decorators" #14131

Merged
merged 2 commits into from
Nov 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/source/generics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ Before parameter specifications, here's how one might have annotated the decorat

.. code-block:: python

from typing import Callable, TypeVar
from typing import Any, Callable, TypeVar, cast

F = TypeVar('F', bound=Callable[..., Any])

Expand All @@ -650,8 +650,8 @@ and that would enable the following type checks:

.. code-block:: python

reveal_type(a) # str
add_forty_two('x') # Type check error: incompatible type "str"; expected "int"
reveal_type(a) # Revealed type is "builtins.int"
add_forty_two('x') # Argument 1 to "add_forty_two" has incompatible type "str"; expected "int"


Note that the ``wrapper()`` function is not type-checked. Wrapper
Expand Down