bpo-32226: PEP 560: improve typing module - #4906
Conversation
|
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. |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
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. raiseTypeErrorinstead of returningTrueas before.repr()for unsubscripted generics coincides withrepr()for normal (non-generic) classes, like<class '__main__.MyGeneric'>. However all things intypingthat 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_Protocoluntil PEP 544 is accepted and the "real"Protocolis 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