-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Stop inheriting Sized in collection ABCs #2658
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
Instead define abstract __len__ in affected classes. Fixes #2655 without breaking rominf/ordered-set-stubs#1
stdlib/3/typing.pyi
Outdated
def __len__(self) -> int: ... | ||
|
||
class Sequence(_Collection[_T_co], Reversible[_T_co], Generic[_T_co]): | ||
class Sequence(Iterable[_T_co], Container[_T_co], Reversible[_T_co], Generic[_T_co]): |
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.
Maybe preserve _Collection
here, as otherwise mypy could infer a less precise type for some type joins? Then you could leave out __len__
as it would be inherited.
You declare |
Some of the ABCs define various concrete methods that can act as default implementations. |
To incorporate python/typeshed#2658
To incorporate python/typeshed#2658
Instead define abstract __len__ in affected classes. Fixes python#2655 without breaking rominf/ordered-set-stubs#1
Instead define abstract len in affected classes.
Fixes #2655 without breaking
rominf/ordered-set-stubs#1