https://github.com/levsh/cwtch
Python Data Classes with validation and views
https://github.com/levsh/cwtch
dataclasses python validation views
Last synced: 6 months ago
JSON representation
Python Data Classes with validation and views
- Host: GitHub
- URL: https://github.com/levsh/cwtch
- Owner: levsh
- License: mit
- Created: 2023-09-08T17:48:36.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-26T16:38:05.000Z (about 2 years ago)
- Last Synced: 2024-04-25T20:20:20.590Z (about 2 years ago)
- Topics: dataclasses, python, validation, views
- Language: Python
- Homepage:
- Size: 662 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## cwtch [wip] - Python `dataclasses` with validation and views.
[Documentation](https://levsh.github.io/cwtch)


[](https://opensource.org/licenses/MIT)
```python
In [1]: from cwtch import dataclass, field
In [2]: @dataclass
...: class M:
...: i: int
...: s: str = field(validate=False)
...:
In [3]: M(i=1, s='s')
Out[3]: M(i=1, s='s')
In [4]: M(i='i', s='s')
---------------------------------------------------------------------------
ValidationError Traceback (most recent call last)
Cell In[4], line 1
----> 1 M(i='i', s='s')
File :32, in __init__(__cwtch_self__, i, s, **__extra_kwds)
ValidationError:
Type: -->
Path: ['i']
ValidationError:
Type: -->
Input: 'i'
ValueError: invalid literal for int() with base 10: 'i'
```