-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
invalid error when writing to an abstract property in an abstract class #3011
Comments
I think this is also a repro: import abc
class C(metaclass=abc.ABCMeta):
@abc.abstractproperty
def foo(self) -> int: pass
@classmethod
def bar(cls) -> None:
cls.foo = 0 This gives a similar error on the last line:
But is it really wrong? You're trying to dynamically patch the definition of the property in the class. |
my intent is to define an abstract property |
What you want is a class property. There's no stdlib support for those, but IIRC there are some hints on StackOverflow. I assume that what you tried doesn't work at runtime either. |
indeed i want an abstract class property. it does actually work that way, however it doesn't fail as expected if a subclass doesn't define that class property. |
i have this piece of code:
and mypy 0.501 yields this for the last line:
my interpretation is, that
Callable
relates toabc.abstractproperty
.The text was updated successfully, but these errors were encountered: