Skip to content

Commit 46b05a4

Browse files
authored
Modernizing guide: Mention TypeGuard/TypeIs (#1887)
1 parent b2d1056 commit 46b05a4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/guides/modernizing.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,3 +341,16 @@ Update your imports to use the new locations::
341341
from collections.abc import Hashable, Sized
342342

343343
def f(x: Hashable) -> Sized: ...
344+
345+
``typing.TypeGuard``
346+
====================
347+
348+
*Available since:* Python 3.13, typing-extensions
349+
350+
:data:`TypeIs <typing.TypeIs>` is an alternative to
351+
:data:`TypeGuard <typing.TypeGuard>` that usually has more intuitive
352+
behavior, but has other restrictions. See the documentation for
353+
:data:`TypeIs <typing.TypeIs>` for more information.
354+
355+
Review existing uses of :data:`TypeGuard <typing.TypeGuard>` to see if they
356+
should be replaced with :data:`TypeIs <typing.TypeIs>`.

0 commit comments

Comments
 (0)