Основы
Синтакстис cwtch dataclass очень похож на стандартный dataclasses.dataclass.
Info
С настройками по умолчанию входные аргументы при создании экземпляра класса будут провалидированы согласно аннотации типов.
В случае ошибки валидации будет выброшено исключение ValidationError.
>>> print(M(i='a', s='s', b=True))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 32, in __init__
cwtch.errors.ValidationError:
Type: --> <class '__main__.M'>
Path: ['i']
ValidationError:
Type: <class 'str'> --> <class 'int'>
Input: 'a'
ValueError: invalid literal for int() with base 10: 'a'