Open SoundsSerious opened 3 years ago
This throws an error like:
<ipython-input-12-7baf0268d8f2> in TestClass()
7 class TestClass(BaseClass):
8
----> 9 @value.default
10 def _not_value(self):
11 return 20
NameError: name 'value' is not defined
I don't understand why this wouldn't work, but it seems attrs is heavily reworking the new / init system so its easy for something like this to go over my head.
Shouldn't TestClass inherit value from BaseClass?
Is there a work around?
seems like this is more of a python issue https://stackoverflow.com/questions/3782040/python-decorators-that-are-part-of-a-base-class-cannot-be-used-to-decorate-membe
Yeah… this isn't attrs
.
@wsanchez i understand closing this as it isn't something python directly supports, however it seems to be a strongly suggested method from the attrs docs which doesn't work in the case of subclasses.
In reviewing other issues before I posted this one, I found a solution that could potentially alleviate this by relying on the attrs
namespace:
@attr.default('value'):
def _not_value(self):
....
Ah, let's re-open for consideration in the docs.
My framework relies on (smart) subclassing, but I've also got it to work with attrs mostly. Running into a problem like the following.