From a5b63cb1404177f0588a1166dfd22aca0e9543b3 Mon Sep 17 00:00:00 2001 From: David Foster Date: Sun, 29 Sep 2024 08:39:10 -0400 Subject: [PATCH] PEP 747: Fix code block formatting. Fix grammar. (#4006) --- peps/pep-0747.rst | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/peps/pep-0747.rst b/peps/pep-0747.rst index 5a4396b12b2..1d5483ad77d 100644 --- a/peps/pep-0747.rst +++ b/peps/pep-0747.rst @@ -26,7 +26,7 @@ an overly-wide type like ``object``, which makes some use cases impossible and generally reduces type safety. This PEP addresses this limitation by introducing a new special form ``typing.TypeForm``. -This PEP makes no changes to the Python grammar. ``TypeForm`` is +This PEP makes no changes to the Python grammar. Correct usage of ``TypeForm`` is intended to be enforced only by type checkers, not by the Python runtime. @@ -95,13 +95,10 @@ would benefit from ``TypeForm``: - Assignability checkers: - Determines whether a value is assignable to a specified type - - Pattern 1: - - ``def is_assignable[T](value: object, typx: TypeForm[T]) -> TypeIs[T]`` - - Pattern 2: + - Pattern 1: ``def is_assignable[T](value: object, typx: TypeForm[T]) -> TypeIs[T]`` - ``def is_match[T](value: object, typx: TypeForm[T]) -> TypeGuard[T]`` + - Pattern 2: ``def is_match[T](value: object, typx: TypeForm[T]) -> TypeGuard[T]`` - Examples: beartype.\ `is_bearable`_, trycast.\ `isassignable`_, typeguard.\ `check_type`_, xdsl.\ `isa`_ @@ -119,7 +116,9 @@ would benefit from ``TypeForm``: - Pattern 1: - ``def convert[T](value: object, typx: TypeForm[T]) -> T`` + :: + + def convert[T](value: object, typx: TypeForm[T]) -> T - Examples: cattrs.BaseConverter.\ `structure`_, trycast.\ `checkcast`_, typedload.\ `load`_