classification
Title: Implement PEP 647 (User-Defined Type Guards) in typing.py
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.10
process
Status: closed Resolution: fixed
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-27 15:59 by kj. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 25282 merged kj, 2021-04-08 16:28
PR 25660 merged kj, 2021-04-27 14:44
Messages (6)
msg390436 - (view) Author: Ken Jin (kj) * (Python committer) Date: 2021-04-07 14:27
PEP 647 was recently accepted by the SC:
https://mail.python.org/archives/list/python-dev@python.org/thread/2ME6F6YUVKHOQYKSHTVQQU5WD4CVAZU4/

I'd like to work on the implementation for typing.py 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 committer) Date: 2021-04-08 16:33
> I assume that this will be pretty simple, right?

Yep! The PR speaks for itself ;). typing.py 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.
msg392078 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-04-27 14:31
New changeset 05ab4b60ab3dae61ee75692b6624537d4f3fdf85 by Ken Jin in branch 'master':
bpo-43766: Implement PEP 647 (User-Defined Type Guards) in typing.py (#25282)
https://github.com/python/cpython/commit/05ab4b60ab3dae61ee75692b6624537d4f3fdf85
msg392095 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-04-27 15:55
New changeset 99fdd782007db86f20aeb302b2ceaf79ce1ae2ba by Ken Jin in branch 'master':
bpo-43766: Fix TypeGuard docs (#25660)
https://github.com/python/cpython/commit/99fdd782007db86f20aeb302b2ceaf79ce1ae2ba
msg392097 - (view) Author: Ken Jin (kj) * (Python committer) Date: 2021-04-27 15:59
Guido, thanks so much for reviewing the docs for TypeGuard so thoroughly even with how busy you are. I hope you enjoy your upcoming vacation :).

I'm closing this issue as all PRs have landed. Please don't hesitate to re-open this if you feel something's amiss. Thanks!
History
Date User Action Args
2021-04-27 15:59:43kjsetstatus: open -> closed
resolution: fixed
messages: + msg392097

stage: patch review -> resolved
2021-04-27 15:55:22gvanrossumsetmessages: + msg392095
2021-04-27 14:44:57kjsetpull_requests: + pull_request24351
2021-04-27 14:31:15gvanrossumsetmessages: + msg392078
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