Repository navigation
Fix abstract classes for Python 3 - #2239
Merged
Merged
Conversation
ilevkivskyi
reviewed
Jun 16, 2018
| if sys.version_info >= (3, 6): | ||
| @runtime | ||
| class Collection(Sized, Iterable[_T_co], Container[_T_co], Protocol[_T_co]): ... | ||
| class Collection(Sized, Iterable[_T_co], Container[_T_co], Protocol[_T_co], metaclass=ABCMeta): ... |
Member
There was a problem hiding this comment.
Hm, I think this should be not needed. Having an explicit Protocol base should be enough. Protocols can't be instantiated at runtime anyway.
Member
Author
There was a problem hiding this comment.
Makes sense, I can add that to my mypy PR.
Member
Author
There was a problem hiding this comment.
Done, changed it in mypy here: python/mypy@e505c0d.
| else: | ||
| @runtime | ||
| class _Collection(Sized, Iterable[_T_co], Container[_T_co], Protocol[_T_co]): ... | ||
| class _Collection(Sized, Iterable[_T_co], Container[_T_co], Protocol[_T_co], metaclass=ABCMeta): ... |
ilevkivskyi
approved these changes
Jun 16, 2018
yedpodtrzitko
pushed a commit
to yedpodtrzitko/typeshed
that referenced
this pull request
Jan 23, 2019
* add metaclass=ABCMeta to some classes * mark some more classes as explicitly abstract * make some more classes concrete
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #1476 and python/mypy#5223.
This makes typeshed pass in Python 3.7 under my mypy PR (and probably in all of Python 3; haven't tried yet). I'll send more PRs for 2.7.
This found an embarrassing typo in the contextvars stub I had previously written.
I changed
google.protobuf.internal.containers.BaseContainerinto aSequenceinstead ofMutableSequenceto reflect the implementation at https://github.com/google/protobuf/blob/master/python/google/protobuf/internal/containers.py#L185.I similarly changed the base class of
urllib3.response.HTTPResponseto match the implementation.