Skip to content
/ cwtch Public

Python Data Classes with validation and views

License

Notifications You must be signed in to change notification settings

levsh/cwtch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'

About

Python Data Classes with validation and views

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published