-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Collection
is Sized
#8977
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
Collection
is Sized
#8977
Conversation
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.
Hm, the decision not to implement Sized in Collection seems pretty intentional.
Looks like this goes back to #2658 , and was maybe done for Python 2 reasons?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Considering that primer does not complain and the change back in 2018 alludes to Python 2/3 problems or problems that may be fixed in mypy 0.650, this looks good to me. But maybe @gvanrossum has some recollection about this?
Or @JukkaL :) |
This change seems fine, since the original motivation was Python 2/3 compatibility concerns, and the mypy primer output is clean. |
I think that it is a good idea to copy original samples to our test cases. |
pyright has a different opinion:
Ok, a test case won't quite work. But, here's my manual test case for this:
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Looks like this change breaks mypy: python/mypy#13977 Reproduce with e.g. The two quickest fixes are either:
or:
Which do people prefer? |
I'd prefer removing the metaclass, I don't think we need it there. |
I think this change caused a false positive error that I'm seeing. More info in #9296. |
This reverts commit 5bbba5d.
See https://github.com/python/cpython/blob/ad1dc3ebb6aadaeeeacde13d4ed2d62bf302bf62/Lib/_collections_abc.py#L431