I have the following attrs class:
from attrs import define, field
@define
class Foo:
bar: int = field()
@bar.validator
def check(self, attribute, value):
...
It works normally at runtime, as expected:
lorem = Foo(42) # Fine
ipsum = Foo('') # Expected type 'int', got 'str' instead
However, PyCharm is giving me a warning about @bar.validator (this is a known bug):
Unresolved attribute reference 'validator' for class 'int'
I don't want to define module-level functions, nor can I stuff everything into lambdas. What other (Pythonic) choices do I have?