-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PEP 585: updates green-lighted by Lukasz #1289
Conversation
77c8944
to
b7f8077
Compare
107fbaf
to
be31b19
Compare
- 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
be31b19
to
1480aee
Compare
@@ -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 | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there are still other containers that should be made generic like queue.*Queue
, should the PEP enumerate all of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh also we decided this isn't similar to typing.IO
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yeah. I'll scratch this line. (Now I'm wondering if perhaps we shouldn't have messed with IOBase
in the code branch?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I doubt people will have io.IOBase imported anyway, I'll make a PR to roll that back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, that makes sense. io.IOBase
is not generic in typeshed. I just goofed up here.
* 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
__parameters__
to__args__
, for typing.py compatibilityand io.IO__parameters__
that contains the unique type vars in__args__
(also for typing.py compatibility)