X Tutup
The Wayback Machine - https://web.archive.org/web/20210202065421/https://github.com/python/peps/pull/1289
Skip to content
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

Merged
merged 4 commits into from Feb 6, 2020
Merged

PEP 585: updates green-lighted by Lukasz #1289

merged 4 commits into from Feb 6, 2020

Conversation

@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented 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
  • pickle and copy should work
  • link to implementation
gvanrossum added 3 commits 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
@gvanrossum gvanrossum force-pushed the pep585-update branch from be31b19 to 1480aee Feb 5, 2020
@@ -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

This comment has been minimized.

@ethanhs

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?

This comment has been minimized.

@gvanrossum

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.

This comment has been minimized.

@ethanhs

ethanhs Feb 5, 2020
Contributor

Okay sounds good!

@@ -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

This comment has been minimized.

@ethanhs

ethanhs Feb 5, 2020
Contributor

Oh also we decided this isn't similar to typing.IO, right?

This comment has been minimized.

@gvanrossum

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?)

This comment has been minimized.

@ethanhs

ethanhs Feb 5, 2020
Contributor

Yeah I doubt people will have io.IOBase imported anyway, I'll make a PR to roll that back.

This comment has been minimized.

@gvanrossum

gvanrossum Feb 5, 2020
Author Member

OK, that makes sense. io.IOBase is not generic in typeshed. I just goofed up here.

@ambv ambv merged commit 7f402ae into master Feb 6, 2020
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@ambv ambv deleted the pep585-update branch Feb 6, 2020
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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
X Tutup