PEP 724: Add the Rationale section (#3447)

This commit is contained in:
Rich Chiodo 2023-09-22 19:02:16 -07:00 committed by GitHub
parent a703204b82
commit a159a9ac58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -83,6 +83,19 @@ The following code sample demonstrates both of these limitations.
return ``TypeGuard`` type was not a subtype of the input type. Refer to return ``TypeGuard`` type was not a subtype of the input type. Refer to
:pep:`647` for examples. :pep:`647` for examples.
Rationale
=========
There are a number of issues where a stricter ``TypeGuard`` would have
been a solution:
* `Python typing issue - TypeGuard doesn't intersect like isinstance <https://github.com/python/typing/issues/1351>`__
* `Pyright issue - TypeGuard not eliminating possibility on branch <https://github.com/microsoft/pyright/issues/3450>`__
* `Pyright issue - Type narrowing for Literal doesn't work <https://github.com/microsoft/pyright/issues/3466>`__
* `Mypy issue - TypeGuard is incompatible with exhaustive check <https://github.com/python/mypy/issues/15305>`__
* `Mypy issue - Incorrect type narrowing for inspect.isawaitable <https://github.com/python/mypy/issues/15520>`__
* `Typeshed issue - asyncio.iscoroutinefunction is not a TypeGuard <https://github.com/python/typeshed/issues/8009>`__
Specification Specification
============= =============