basedmypy
basedmypy copied to clipboard
no error when `abstractmethod` decorator is above `property` decorator
Describe the problem, ie expected/actual result (if it's not blatantly obvious)
AttributeError: attribute '__isabstractmethod__' of 'property' objects is not writable
Gist to reproduce
from abc import abstractmethod
class Foo:
@abstractmethod
@property
def foo(self) -> int:
...
Basedmypy version
No response
Command-line flags
No response
Configuration options from pyproject.toml (and other config files)
No response
Python version used
No response
Operating system and version
No response
So abstractmethod takes a Callable, and in this case we are passing it a property object, which is not callable.
But in reality, all abstractmethod does, is sets an attribute __isabstractmethod__ on the passed object:
def abstractmethod(funcobj):
funcobj.__isabstractmethod__ = True
return funcobj
property is a native class whose attributes can't be arbitrarily set.