-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-32226: PEP 560: improve typing module #4906
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
Conversation
I'm afraid I won't be able to look at this in time for 3.7b1. I trust Serhiy, so I think it's between the two of you. As to which repo should be fixed first, I propose to do the CPython master branch first, backporting to 3.6 if appropriate, and only to the typing repo if it's relevant for Python 2.7. For 3.5 and 3.6 the typing repo isn't used anyways (except by people who set I assume that even Python 2.7 support will be minimal, but we should at least try to keep Protocol support up to date there, and perhaps other new features for which it makes sense. If we didn't have Python 2.7, I'd propose to just close the repo like we did for asyncio -- but I think we can't do that until the Python 2.7 EOL date of 1/1/2020. This could even mean that we could sanitize the typing repo, removing the Python 3 support code. Though I'm not sure what to do with the issue tracker. Should we continue to point people there for fundamental discussions about the type system? |
For the other issues (including Union simplification) I would be happy to see small PRs, one per issue or feature. |
OK, @serhiy-storchaka would you like to make another pass of review? Note that one of the goals of this PR is to simplify the code, so that it is easier to understand, so it would be a good test. If there are some particularly tricky places in code, then you can just flag them, so that I will add comments there. Or you will not have time today/tomorrow then maybe we can just merge as is, to unblock other things that depend on this PR? |
@serhiy-storchaka If you don't have time to review this now, then I think we shouldn't wait more. I am going to merge this in an hour or so. Please let me know if you still want to review this. |
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 know too small about this module for making deep review, but at surface I don't see anything wrong. If there are some problems, I think they can be resolved at the beta stage in separate issues.
OK. |
This change did not update Doc/library/typing.rst but the note that "The metaclass used by :class: |
@eirrgang You are right, there is no more metaclass for |
PR python#4906 changed the typing.Generic class hierarchy, leaving an outdated comment in the library reference. User-defined Generic ABCs now must get a abc.ABCMeta metaclass from something other than typing.Generic inheritance.
PR python#4906 changed the typing.Generic class hierarchy, leaving an outdated comment in the library reference. User-defined Generic ABCs now must get a abc.ABCMeta metaclass from something other than typing.Generic inheritance.
PR pythonGH-4906 changed the typing.Generic class hierarchy, leaving an outdated comment in the library reference. User-defined Generic ABCs now must get a abc.ABCMeta metaclass from something other than typing.Generic inheritance. (cherry picked from commit d47f0dd) Co-authored-by: M. Eric Irrgang <mei2n@virginia.edu>
PR pythonGH-4906 changed the typing.Generic class hierarchy, leaving an outdated comment in the library reference. User-defined Generic ABCs now must get a abc.ABCMeta metaclass from something other than typing.Generic inheritance. (cherry picked from commit d47f0dd) Co-authored-by: M. Eric Irrgang <mei2n@virginia.edu>
PR GH-4906 changed the typing.Generic class hierarchy, leaving an outdated comment in the library reference. User-defined Generic ABCs now must get a abc.ABCMeta metaclass from something other than typing.Generic inheritance. (cherry picked from commit d47f0dd) Co-authored-by: M. Eric Irrgang <mei2n@virginia.edu>
PR GH-4906 changed the typing.Generic class hierarchy, leaving an outdated comment in the library reference. User-defined Generic ABCs now must get a abc.ABCMeta metaclass from something other than typing.Generic inheritance. (cherry picked from commit d47f0dd) Co-authored-by: M. Eric Irrgang <mei2n@virginia.edu>
PR pythonGH-4906 changed the typing.Generic class hierarchy, leaving an outdated comment in the library reference. User-defined Generic ABCs now must get a abc.ABCMeta metaclass from something other than typing.Generic inheritance. (cherry picked from commit d47f0dd) Co-authored-by: M. Eric Irrgang <mei2n@virginia.edu>
PR python#4906 changed the typing.Generic class hierarchy, leaving an outdated comment in the library reference. User-defined Generic ABCs now must get a abc.ABCMeta metaclass from something other than typing.Generic inheritance.
This is not ready for a detailed review, but updates to tests can be already discussed. You can also play with the new implementation but some minor details can change.
Here is the summary of changes in tests (two first are mentioned in the PEP):
issublcass(List[int], List)
etc. raiseTypeError
instead of returningTrue
as before.repr()
for unsubscripted generics coincides withrepr()
for normal (non-generic) classes, like<class '__main__.MyGeneric'>
. However all things intyping
that are not class objects and all subscripted generics use existing "fancy"repr()
, liketyping.List[__main__.C[int]]
.ForwardRef
, on the contrary, I add underscore to_Protocol
until PEP 544 is accepted and the "real"Protocol
is added totyping
.An important question is how will we keep stdlib version and the backport on PyPI in sync? One possible option is just manually copy useful updates/test between them.
cc: @gvanrossum
https://bugs.python.org/issue32226