-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Makes Array
abstract
#6361
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
Makes Array
abstract
#6361
Conversation
I have to support |
This comment has been minimized.
This comment has been minimized.
Or not. It does not work in runtime. There are just some confusing examples in the CPython's source code. |
This feels like it maybe relies on a mypy bug at the moment. Adding |
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This is by design. It allows defining ABCs that are only checked during static type checking but not at runtime. This can be helpful to avoid metaclass conflicts, for example. |
Thanks, TIL! |
Any ideas how can we fix this
First ideaThis does not work with mypy: @property
@abstractmethod
def _length_(self) -> int: ...
@_length_.setter
@abstractmethod
def _length_(self, value: int) -> None: ...
@property
@abstractmethod
def _type_(self) -> type: ...
@_type_.setter
@abstractmethod
def _type_(self, value: type) -> None: ...
This does not seem right to me: looks like this code should be accepted by mypy:
I will open a new issue for it: python/mypy#11601 |
CC @rchen152 |
Huh, looks like the issue might be that pytype thinks that the property and setter methods are overloads? I'll take a look. |
I've sent a fix for the pytype issue out for review. Hopefully, I'll be able to do a release tomorrow; if not, it'll have to wait until next Monday (after Thanksgiving). |
See python/typeshed#6361. PiperOrigin-RevId: 412119101
I've released pytype-2021.11.24, which should fix the pytype_test failure. |
@rchen152 thank you! 🎉 |
It is required to solve #6361
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Thanks everyone! |
Now, this code:
Raises:
Tested locally with recent mypy.
Refs #6349