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: Implement PEP 585 (Type Hinting Generics In Standard Collections)
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya, ethan smith, gousaiyang, gvanrossum, lukasz.langa, miss-islington, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2020-01-28 17:16 by gvanrossum, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18239 merged gvanrossum, 2020-01-28 17:17
PR 19415 merged BTaskaya, 2020-04-07 20:56
PR 19417 merged ethan smith, 2020-04-07 21:55
PR 19418 merged BTaskaya, 2020-04-07 22:24
PR 19421 merged ethan smith, 2020-04-07 22:46
PR 19422 merged ethan smith, 2020-04-07 22:59
PR 19423 merged BTaskaya, 2020-04-07 23:26
PR 19425 merged ethan smith, 2020-04-07 23:34
PR 19427 merged ethan smith, 2020-04-08 00:02
PR 19434 closed BTaskaya, 2020-04-08 12:15
PR 19435 closed BTaskaya, 2020-04-08 12:45
PR 19469 merged yan12125, 2020-04-11 02:57
PR 19497 merged ethan smith, 2020-04-13 07:00
PR 20045 merged BTaskaya, 2020-05-12 00:29
PR 22619 merged gousaiyang, 2020-10-09 19:04
PR 22624 merged gousaiyang, 2020-10-09 20:34
Messages (29)
msg360885 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-01-28 17:16
See PEP 585, which is still under review and may change in response to this work.

https://www.python.org/dev/peps/pep-0585/
msg364311 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2020-03-16 11:17
Submitted a request for consideration by the Steering Council: https://github.com/python/steering-council/issues/21
msg365357 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-03-30 21:38
The SC approved the PEP!

Łukasz, do you want to submit the PR to update the PEP status?

We should get the implementation reviewed (e.g. by Serhiy) and land it before alpha 6 goes out, April 22 (we should aim for a week before at least).
msg365914 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-07 16:50
New changeset 48b069a003ba6c684a9ba78493fbbec5e89f10b8 by Guido van Rossum in branch 'master':
bpo-39481: Implementation for PEP 585 (#18239)
https://github.com/python/cpython/commit/48b069a003ba6c684a9ba78493fbbec5e89f10b8
msg365916 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-07 16:51
The base implementation has landed. We still need docs, and I'm sure that the alpha and beta release cycle will find small things that need to be improved.

Perhaps the next priority is an update for Doc/whatsnew/3.9.rst.
msg365936 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-04-07 20:35
@gvanrossum is new types going to support generic alias protocol or this subset will be kept? Like typeshed uses os.DirEntry as a generic, but in reality it is not. (https://github.com/python/cpython/pull/17561)
msg365943 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-07 20:57
Ethan Smith produced a list of types that are Generic in typeshed but not in the stdlib. So these could be added.

https://github.com/gvanrossum/cpython/pull/1#issuecomment-582781121
msg365949 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-07 21:37
New changeset f9dd51e7db27d04e0b716d41a2804d5acbf145d1 by Batuhan Taşkaya in branch 'master':
bpo-39481: Make os.DirEntry generic (GH-19415)
https://github.com/python/cpython/commit/f9dd51e7db27d04e0b716d41a2804d5acbf145d1
msg366102 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-10 04:05
New changeset 2fa67df605e4b0803e7e3aac0b85d851b4b4e09a by Batuhan Taşkaya in branch 'master':
bpo-39481: PEP 585 for ipaddress.py (GH-19418)
https://github.com/python/cpython/commit/2fa67df605e4b0803e7e3aac0b85d851b4b4e09a
msg366104 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-10 04:25
New changeset 7c4185d62d4aec486d82c3ad02acd878db2d3537 by Ethan Smith in branch 'master':
bpo-39481: PEP 585 for enumerate, AsyncGeneratorType, mmap (GH-19421)
https://github.com/python/cpython/commit/7c4185d62d4aec486d82c3ad02acd878db2d3537
msg366105 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-10 04:34
At this speed I can merge about 3 PRs per hour. I'll be back tomorrow.
msg366106 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-10 04:47
New changeset e3ec44d692d9442e640cf5b2d8708157a65cec3e by Ethan Smith in branch 'master':
bpo-39481: PEP 585 for difflib, filecmp, fileinput (#19422)
https://github.com/python/cpython/commit/e3ec44d692d9442e640cf5b2d8708157a65cec3e
msg366108 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-04-10 05:08
How are ipaddress and mmap generic?
msg366109 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-10 05:10
Check typeshed
msg366131 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-10 14:46
New changeset 0361556537686f857f1025ead75e6af4ca7cc94a by Batuhan Taşkaya in branch 'master':
bpo-39481: PEP 585 for a variety of modules (GH-19423)
https://github.com/python/cpython/commit/0361556537686f857f1025ead75e6af4ca7cc94a
msg366288 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-04-13 09:12
I tested the following example:

import ipaddress, mmap

x: ipaddress.IPv4Network[int]
y: mmap.mmap[int]

MyPy produces errors:

t.py:4: error: "IPv4Network" expects no type arguments, but 1 given
t.py:5: error: "mmap" expects no type arguments, but 1 given

This is because mmap and IPv4Network are not generic types in typeshed. _BaseNetwork and _mmap are generic types, but IPv4Network and mmap are normal classes. The former are implementation detail of typeshed. _mmap does not exist in the stdlib, and _BaseNetwork in typeshed and the stdlib are different things.
msg366309 - (view) Author: Ethan Smith (ethan smith) * Date: 2020-04-13 12:36
Hm, yeah it appears my methodology was too loose. Thank you for catching
these. I will go through and test the rest (if you haven't yet) later today
and make a PR to revert anything that needs it. Thanks! (and sorry)

On Mon, Apr 13, 2020 at 2:12 AM Serhiy Storchaka <report@bugs.python.org>
wrote:

>
> Serhiy Storchaka <storchaka+cpython@gmail.com> added the comment:
>
> I tested the following example:
>
> import ipaddress, mmap
>
> x: ipaddress.IPv4Network[int]
> y: mmap.mmap[int]
>
> MyPy produces errors:
>
> t.py:4: error: "IPv4Network" expects no type arguments, but 1 given
> t.py:5: error: "mmap" expects no type arguments, but 1 given
>
> This is because mmap and IPv4Network are not generic types in typeshed.
> _BaseNetwork and _mmap are generic types, but IPv4Network and mmap are
> normal classes. The former are implementation detail of typeshed. _mmap
> does not exist in the stdlib, and _BaseNetwork in typeshed and the stdlib
> are different things.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue39481>
> _______________________________________
>
msg366311 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-04-13 12:52
No, I did not check other changes. These two just looked too suspicious.
msg366333 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-13 22:00
New changeset 25a6833f7945f14cad83509ec73954d0ad70bdb1 by Chih-Hsuan Yen in branch 'master':
bpo-39481: fix test_genericalias on Android (GH-19469)
https://github.com/python/cpython/commit/25a6833f7945f14cad83509ec73954d0ad70bdb1
msg366366 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-14 04:53
New changeset cecf049673da6a24435acd1a6a3b34472b323c97 by Ethan Smith in branch 'master':
bpo-39481: Make functools.cached_property, partial, partialmethod generic (#19427)
https://github.com/python/cpython/commit/cecf049673da6a24435acd1a6a3b34472b323c97
msg366367 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-14 04:54
New changeset 8ef875028a3644a329c87ce420a73793e315143f by Ethan Smith in branch 'master':
bpo-39481: Make weakref and WeakSet generic (GH-19497)
https://github.com/python/cpython/commit/8ef875028a3644a329c87ce420a73793e315143f
msg366464 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-14 23:14
New changeset d01628e411752ee6849f862cae66a1c69fe512b7 by Ethan Smith in branch 'master':
bpo-39481: PEP 585 for dataclasses, mailbox, contextvars (GH-19425)
https://github.com/python/cpython/commit/d01628e411752ee6849f862cae66a1c69fe512b7
msg366468 - (view) Author: Ethan Smith (ethan smith) * Date: 2020-04-15 00:46
I went through the list I generated and it seems that the
ipaddress._BaseNetwork and mmap.mmap cases are the only one I saw that
shouldn't be generic. I will submit a PR to revert those. The only item
left after that which I know of is _lru_cache_wrapper.

On Tue, Apr 14, 2020 at 4:14 PM Guido van Rossum <report@bugs.python.org>
wrote:

>
> Guido van Rossum <guido@python.org> added the comment:
>
>
> New changeset d01628e411752ee6849f862cae66a1c69fe512b7 by Ethan Smith in
> branch 'master':
> bpo-39481: PEP 585 for dataclasses, mailbox, contextvars (GH-19425)
>
> https://github.com/python/cpython/commit/d01628e411752ee6849f862cae66a1c69fe512b7
>
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue39481>
> _______________________________________
>
msg366476 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-15 01:59
Thanks!
-- 
--Guido (mobile)
msg367244 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-04-25 00:20
In commit 0e80b561d442769631d66f1cc8813ac30f97378e a What's New section was added.
msg368697 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-05-12 02:32
New changeset f3a5b7ada0c951f317dbd307de4b410e58d3e1b3 by Batuhan Taskaya in branch 'master':
bpo-39481: remove generic classes from ipaddress/mmap (GH-20045)
https://github.com/python/cpython/commit/f3a5b7ada0c951f317dbd307de4b410e58d3e1b3
msg374286 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-07-25 21:57
This can be closed. It needs docs though; there's a separate issue for that (issue40814).
msg378343 - (view) Author: miss-islington (miss-islington) Date: 2020-10-09 20:00
New changeset b2c0a43699bd9023a69e3fa554f5488a2e17e278 by Saiyang Gou in branch 'master':
bpo-39481: Fix duplicate SimpleQueue type in test_genericalias.py (GH-22619)
https://github.com/python/cpython/commit/b2c0a43699bd9023a69e3fa554f5488a2e17e278
msg378535 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-10-12 23:52
New changeset 1c217652b690c184b43d8e2b6529a60a14e64328 by Saiyang Gou in branch '3.9':
[3.9] bpo-39481: Fix duplicate SimpleQueue type in test_genericalias.py (GH-22619) (#22624)
https://github.com/python/cpython/commit/1c217652b690c184b43d8e2b6529a60a14e64328
History
Date User Action Args
2022-04-11 14:59:25adminsetgithub: 83662
2020-10-12 23:52:11gvanrossumsetmessages: + msg378535
2020-10-10 01:28:07yan12125setnosy: - yan12125
2020-10-09 20:34:07gousaiyangsetpull_requests: + pull_request21604
2020-10-09 20:00:28miss-islingtonsetnosy: + miss-islington
messages: + msg378343
2020-10-09 19:04:58gousaiyangsetnosy: + gousaiyang

pull_requests: + pull_request21599
2020-07-25 21:57:06gvanrossumsetstatus: open -> closed
resolution: fixed
messages: + msg374286

stage: patch review -> resolved
2020-05-12 02:32:47gvanrossumsetmessages: + msg368697
2020-05-12 00:29:24BTaskayasetpull_requests: + pull_request19354
2020-04-25 00:20:55gvanrossumsetmessages: + msg367244
2020-04-15 01:59:14gvanrossumsetmessages: + msg366476
2020-04-15 00:46:25ethan smithsetmessages: + msg366468
2020-04-14 23:14:21gvanrossumsetmessages: + msg366464
2020-04-14 04:54:43gvanrossumsetmessages: + msg366367
2020-04-14 04:53:11gvanrossumsetmessages: + msg366366
2020-04-13 22:00:31gvanrossumsetmessages: + msg366333
2020-04-13 12:52:36serhiy.storchakasetmessages: + msg366311
2020-04-13 12:36:57ethan smithsetmessages: + msg366309
2020-04-13 09:12:29serhiy.storchakasetmessages: + msg366288
2020-04-13 07:00:41ethan smithsetpull_requests: + pull_request18848
2020-04-11 02:57:15yan12125setnosy: + yan12125
pull_requests: + pull_request18824
2020-04-10 14:46:43gvanrossumsetmessages: + msg366131
2020-04-10 05:10:20gvanrossumsetmessages: + msg366109
2020-04-10 05:08:53serhiy.storchakasetmessages: + msg366108
2020-04-10 04:47:38gvanrossumsetmessages: + msg366106
2020-04-10 04:34:18gvanrossumsetmessages: + msg366105
2020-04-10 04:25:59gvanrossumsetmessages: + msg366104
2020-04-10 04:05:01gvanrossumsetmessages: + msg366102
2020-04-08 12:45:42BTaskayasetpull_requests: + pull_request18789
2020-04-08 12:15:02BTaskayasetpull_requests: + pull_request18788
2020-04-08 00:02:11ethan smithsetpull_requests: + pull_request18785
2020-04-07 23:34:04ethan smithsetpull_requests: + pull_request18782
2020-04-07 23:26:16BTaskayasetpull_requests: + pull_request18781
2020-04-07 22:59:05ethan smithsetpull_requests: + pull_request18780
2020-04-07 22:46:11ethan smithsetpull_requests: + pull_request18779
2020-04-07 22:24:31BTaskayasetpull_requests: + pull_request18778
2020-04-07 21:55:13ethan smithsetpull_requests: + pull_request18777
2020-04-07 21:38:38ethan smithsetnosy: + ethan smith
2020-04-07 21:37:22gvanrossumsetmessages: + msg365949
2020-04-07 20:57:51gvanrossumsetmessages: + msg365943
2020-04-07 20:56:37BTaskayasetpull_requests: + pull_request18775
2020-04-07 20:41:21serhiy.storchakasetnosy: + serhiy.storchaka
2020-04-07 20:35:46BTaskayasetnosy: + BTaskaya
messages: + msg365936
2020-04-07 16:51:56gvanrossumsetmessages: + msg365916
2020-04-07 16:50:09gvanrossumsetmessages: + msg365914
2020-03-30 21:38:01gvanrossumsetmessages: + msg365357
2020-03-16 11:17:19lukasz.langasetnosy: + lukasz.langa
messages: + msg364311
2020-01-28 17:17:26gvanrossumsetkeywords: + patch
stage: patch review
pull_requests: + pull_request17620
2020-01-28 17:16:57gvanrossumcreate