smarie/python-autoclass

Wrong function name in validation error message of field setter

smarie opened this issue · 0 comments

from autoclass import autoclass
from pytypes import typechecked
from valid8 import validate_arg, is_multiple_of
from mini_lambda import s, x, Len

@typechecked
@autoclass
class House:
    @validate_arg('name', Len(s) > 0)
    @validate_arg('surface', (x >= 0) & (x < 10000), is_multiple_of(100))
    def __init__(self, name: str, surface: int = 100):
        pass

If we create an object and then set a wrong value for the field, the exception contains a wrong reference to __init__ function:

o = House('helo')
o.surface = 150