This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: typing.py get_args and get_origin should support PEP 604 and 612
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, kj, levkivskyi, miss-islington
Priority: normal Keywords: patch

Created on 2020-12-25 15:19 by kj, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 23942 merged kj, 2020-12-25 15:43
PR 23963 merged kj, 2020-12-27 09:41
PR 23977 merged miss-islington, 2020-12-28 20:06
Messages (4)
msg383747 - (view) Author: Ken Jin (kj) * (Python committer) Date: 2020-12-25 15:19
Currently get_args doesn't work for PEP 604 Union:

>>> get_args(int | str)

or new Callables with PEP 612:

>>> P = ParamSpec('P)
>>> get_args(Callable[P, int])
([~P], <class 'int'>)

get_origin doesn't work with PEP 604 Unions:

>>> get_origin(int | str)


PS: the fix has to be backported partly to 3.9. Because get_args doesn't handle collections.abc.Callable either.
msg383924 - (view) Author: miss-islington (miss-islington) Date: 2020-12-28 20:06
New changeset 4140f10a16f06c32fd49f9e21fb2a53abe7357f0 by Ken Jin in branch 'master':
bpo-42740: Fix get_args for PEP 585 collections.abc.Callable (GH-23963)
https://github.com/python/cpython/commit/4140f10a16f06c32fd49f9e21fb2a53abe7357f0
msg383925 - (view) Author: miss-islington (miss-islington) Date: 2020-12-28 20:26
New changeset 03e571f1d5f3e7a11f33bb9f47dd4acedf17b166 by Miss Islington (bot) in branch '3.9':
bpo-42740: Fix get_args for PEP 585 collections.abc.Callable (GH-23963)
https://github.com/python/cpython/commit/03e571f1d5f3e7a11f33bb9f47dd4acedf17b166
msg383945 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-12-29 02:26
New changeset efb1f0918fad2ba3346a986b0e958dc5753a7bbe by Ken Jin in branch 'master':
bpo-42740: Support PEP 604, 612 for typing.py get_args and get_origin (GH-23942)
https://github.com/python/cpython/commit/efb1f0918fad2ba3346a986b0e958dc5753a7bbe
History
Date User Action Args
2022-04-11 14:59:39adminsetgithub: 86906
2020-12-29 02:29:46gvanrossumsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-12-29 02:26:33gvanrossumsetmessages: + msg383945
2020-12-28 20:26:47miss-islingtonsetmessages: + msg383925
2020-12-28 20:06:41miss-islingtonsetpull_requests: + pull_request22822
2020-12-28 20:06:27miss-islingtonsetnosy: + miss-islington
messages: + msg383924
2020-12-27 09:41:54kjsetpull_requests: + pull_request22808
2020-12-25 15:43:25kjsetkeywords: + patch
stage: patch review
pull_requests: + pull_request22793
2020-12-25 15:19:22kjcreate