PEP 585: updates green-lighted by Lukasz #1289
Merged
Conversation
This was referenced Jan 30, 2020
- Rename __parameters__ to __args__, for typing.py compatibility
- Genericize, re.{Pattern,Match} and io.IO
- list != list[int], but list[int] == list[int] (and list[str] != list[int])
- Add a lazy __parameters__ that contains the unique type vars in __args__ (also for typing.py compatibility)
- make dict[str][str] fail, but dict[T, str][int] return dict[int, str]
- expose proxy type as types.GenericAlias
| @@ -112,6 +112,9 @@ Python 3.9, the following collections become generic using | |||
| * ``collections.abc.ValuesView`` | |||
| * ``contextlib.AbstractContextManager`` # typing.ContextManager | |||
| * ``contextlib.AbstractAsyncContextManager`` # typing.AsyncContextManager | |||
| * ``re.Pattern`` # typing.Pattern, typing.re.Pattern | |||
| * ``re.Match`` # typing.Match, typing.re.Match | |||
| * ``io.IO`` # typing.IO, typing.io.IO | |||
|
|
|||
ethanhs
Feb 5, 2020
Contributor
I believe there are still other containers that should be made generic like queue.*Queue, should the PEP enumerate all of them?
I believe there are still other containers that should be made generic like queue.*Queue, should the PEP enumerate all of them?
gvanrossum
Feb 5, 2020
Author
Member
Honestly I think the PEP should stick to things that are currently shadowed in typing.py. Once we have GenericAlias it's easy enough to make other classes generic.
Honestly I think the PEP should stick to things that are currently shadowed in typing.py. Once we have GenericAlias it's easy enough to make other classes generic.
ethanhs
Feb 5, 2020
Contributor
Okay sounds good!
Okay sounds good!
pep-0585.rst
Outdated
| @@ -112,6 +112,9 @@ Python 3.9, the following collections become generic using | |||
| * ``collections.abc.ValuesView`` | |||
| * ``contextlib.AbstractContextManager`` # typing.ContextManager | |||
| * ``contextlib.AbstractAsyncContextManager`` # typing.AsyncContextManager | |||
| * ``re.Pattern`` # typing.Pattern, typing.re.Pattern | |||
| * ``re.Match`` # typing.Match, typing.re.Match | |||
| * ``io.IO`` # typing.IO, typing.io.IO | |||
ethanhs
Feb 5, 2020
Contributor
Oh also we decided this isn't similar to typing.IO, right?
Oh also we decided this isn't similar to typing.IO, right?
gvanrossum
Feb 5, 2020
Author
Member
Oh, yeah. I'll scratch this line. (Now I'm wondering if perhaps we shouldn't have messed with IOBase in the code branch?)
Oh, yeah. I'll scratch this line. (Now I'm wondering if perhaps we shouldn't have messed with IOBase in the code branch?)
ethanhs
Feb 5, 2020
Contributor
Yeah I doubt people will have io.IOBase imported anyway, I'll make a PR to roll that back.
Yeah I doubt people will have io.IOBase imported anyway, I'll make a PR to roll that back.
gvanrossum
Feb 5, 2020
Author
Member
OK, that makes sense. io.IOBase is not generic in typeshed. I just goofed up here.
OK, that makes sense. io.IOBase is not generic in typeshed. I just goofed up here.
mnm678
added a commit
to mnm678/peps
that referenced
this pull request
Oct 22, 2020
* Rename __parameters__ to __args__, for typing.py compatibility
* Genericize, re.{Pattern,Match} and io.IO
* list != list[int], but list[int] == list[int] (and list[str] != list[int])
* Add a lazy __parameters__ that contains the unique type vars in __args__ (also for typing.py compatibility)
* make dict[str][str] fail, but dict[T, str][int] return dict[int, str]
* expose proxy type as types.GenericAlias
* Link to implementation
* Explicitly state that pickling or copying should work
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.


__parameters__to__args__, for typing.py compatibilityand io.IO__parameters__that contains the unique type vars in__args__(also for typing.py compatibility)