Skip to content

Commit

Permalink
Modernizing guide: Mention TypeGuard/TypeIs (#1887)
Browse files Browse the repository at this point in the history
  • Loading branch information
srittau authored Nov 18, 2024
1 parent b2d1056 commit 46b05a4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/guides/modernizing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,16 @@ Update your imports to use the new locations::
from collections.abc import Hashable, Sized

def f(x: Hashable) -> Sized: ...

``typing.TypeGuard``
====================

*Available since:* Python 3.13, typing-extensions

:data:`TypeIs <typing.TypeIs>` is an alternative to
:data:`TypeGuard <typing.TypeGuard>` that usually has more intuitive
behavior, but has other restrictions. See the documentation for
:data:`TypeIs <typing.TypeIs>` for more information.

Review existing uses of :data:`TypeGuard <typing.TypeGuard>` to see if they
should be replaced with :data:`TypeIs <typing.TypeIs>`.

0 comments on commit 46b05a4

Please sign in to comment.