Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 1.16 KB

README.md

File metadata and controls

32 lines (24 loc) · 1.16 KB

cwtch [wip] - Python dataclasses with validation and views.

Documentation

tests coverage License: MIT

In [1]: from cwtch import dataclass, field

In [2]: @dataclass
   ...: class D:
   ...:     i: int
   ...:     s: str = field(validate=False)

In [3]: D(i=1, s='s')
Out[3]: D(i=1, s='s')

In [4]: D(i='i', s='s')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
...
ValidationError                           Traceback (most recent call last)
Cell In[4], line 1
----> 1 D(i='i', s='s')

File <string>:12, in __init__(__cwtch_self__, i, s, **__extra_kwds)

ValidationError: type[ <class '__main__.D'> ] path[ 'i' ]
  type[ <class 'int'> ] input_type[ <class 'str'> ] input_value[ 'i' ]
    ValueError: invalid literal for int() with base 10: 'i'