Title: Implement PEP 647 (User-Defined Type Guards) in
Type: Stage: patch review
Components: Library (Lib) Versions: Python 3.10
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, kj, rhettinger
Priority: normal Keywords: patch

Created on 2021-04-07 14:27 by kj, last changed 2021-04-08 16:33 by kj.

Pull Requests
URL Status Linked Edit
PR 25282 open kj, 2021-04-08 16:28
Messages (3)
msg390436 - (view) Author: Ken Jin (kj) * (Python triager) Date: 2021-04-07 14:27
PEP 647 was recently accepted by the SC:

I'd like to work on the implementation for and any required docs later on (unless someone is already working on it, then I hope you'd let me help too ;). Hopefully I can get it in before the 3.10 beta freeze.

typing_extensions will need a port too, though that is much less urgent at the moment.
msg390458 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-04-07 18:15
Go for it! I assume that this will be pretty simple, right? TypeGuard[X] should show up in __annotations__ as exactly that. It can be implemented in pure Python.
msg390537 - (view) Author: Ken Jin (kj) * (Python triager) Date: 2021-04-08 16:33
> I assume that this will be pretty simple, right?

Yep! The PR speaks for itself ;). has pretty nice internal constructs to make these types of additions a breeze. I'm really grateful to whoever wrote/refactored the _SpecialForm decorator to what it is today.
Date User Action Args
2021-04-08 16:33:44kjsetmessages: + msg390537
2021-04-08 16:28:10kjsetkeywords: + patch
stage: patch review
pull_requests: + pull_request24018
2021-04-07 19:52:13rhettingersetnosy: + rhettinger
2021-04-07 18:15:38gvanrossumsetmessages: + msg390458
2021-04-07 14:27:50kjcreate