When I try to use attribute decorators via auto attributes style, I get an error saying that the name doesn't exist. This doesn't happen if I initiate attributes with attr.ib(). Is this expected behavior?
Here is an example that fails:
@attr.s(auto_attribs=True)
class A:
x: float
@x.validator
def _check_x(self, attrib, value):
print("Validator called.")
print(self, attrib, value)
a = A(5)
gives
Traceback (most recent call last):
File "test.py", line 5, in first
@attr.s(auto_attribs=True)
File "test.py", line 9, in A
@x.validator
NameError: name 'x' is not defined
When I try to use attribute decorators via auto attributes style, I get an error saying that the name doesn't exist. This doesn't happen if I initiate attributes with attr.ib(). Is this expected behavior?
Here is an example that fails:
gives