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)
File /vagrant/dev/cwtch/ext/core.pyx:618, in cwtch.core.make.validate_value_using_validator()
...
ValueError: invalid literal for int() with base 10: 'i'
During handling of the above exception, another exception occurred:
ValidationError Traceback (most recent call last)
...
ValidationError: type=[<class 'int'>] input_type=[<class 'str'>]
E: invalid literal for int() with base 10: 'i'
During handling of the above exception, another exception occurred:
ValidationError Traceback (most recent call last)
Cell In[4], line 1
----> 1 D(i='i', s='s')
File <string>:11, in __init__(__cwtch_self__, i, s, **__cwtch_kwds__)
ValidationError: type=[<class '__main__.D'>] path=['i'] input_type=[<class 'str'>]
type=[<class 'int'>] input_type=[<class 'str'>]
E: invalid literal for int() with base 10: 'i'
In [5]: D(i='1', s=0)
Out[5]: D(i=1, s=0)
-
Notifications
You must be signed in to change notification settings - Fork 0
Python Data Classes with validation and views
License
levsh/cwtch
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Python Data Classes with validation and views
Topics
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published