Skip to content

Commit

Permalink
Suggestion from Carl
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Apr 6, 2024
1 parent c30aa46 commit 86800c4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,12 +838,12 @@ def TypeGuard(self, parameters):
from an incompatible type (e.g., ``list[object]`` to ``list[int]``) or when
the function does not return ``True`` for all instances of the narrowed type.
Using ``-> TypeGuard`` tells the static type checker that for a given
function:
Using ``-> TypeGuard[NarrowedType]`` tells the static type checker that
for a given function:
1. The return value is a boolean.
2. If the return value is ``True``, the type of its argument
is the type inside ``TypeGuard``.
is ``NarrowedType``.
For example::
Expand Down Expand Up @@ -896,15 +896,15 @@ def TypeIs(self, parameters):
are incompatible (e.g., ``list[object]`` to ``list[int]``) or when the
function does not return ``True`` for all instances of the narrowed type.
Using ``-> TypeIs`` tells the static type checker that for a given
function:
Using ``-> TypeIs[NarrowedType]`` tells the static type checker that for
a given function:
1. The return value is a boolean.
2. If the return value is ``True``, the type of its argument
is the intersection of the argument's original type and the
type inside ``TypeIs``.
is the intersection of the argument's original type and
``NarrowedType``.
3. If the return value is ``False``, the type of its argument
is narrowed to exclude the type inside ``TypeIs``.
is narrowed to exclude ``NarrowedType``.
For example::
Expand Down

0 comments on commit 86800c4

Please sign in to comment.