No project description provided
Project description
python-cydantic
conao3's pydantic CLI wrapper.
Install
Install from PyPI
release soon.
Install from Source
poetry install
Usage
generate
Prepare pydantic model named Model
.
import pydantic
class Model(pydantic.BaseModel):
name: str = 'John Doe'
age: int = 20
Generate Model
's schema.
$ cydantic generate -s sample/schema01.py
{
"properties": {
"name": {
"default": "John Doe",
"title": "Name",
"type": "string"
},
"age": {
"default": 20,
"title": "Age",
"type": "integer"
}
},
"title": "Model",
"type": "object"
}
Output using yaml format.
$ cydantic generate -s sample/schema01.py --format yaml
properties:
age:
default: 20
title: Age
type: integer
name:
default: John Doe
title: Name
type: string
title: Model
type: object
validate
$ cydantic validate -s sample/schema01.py -f yaml -i sample/inpt01.json
age: 20
name: conao3
$ cydantic validate -s sample/schema01.py -f yaml -i sample/inpt02.json
age: 18
name: conao3
$ cydantic validate -s sample/schema01.py -f yaml -i sample/inpt03.json
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/conao/dev/repos/python-cydantic/src/cydantic/main.py", line 86, in main
args.handler(args)
File "/Users/conao/dev/repos/python-cydantic/src/cydantic/main.py", line 48, in command_validate
obj = model.model_validate(inpt)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/conao/dev/repos/python-cydantic/.venv/lib/python3.12/site-packages/pydantic/main.py", line 503, in model_validate
return cls.__pydantic_validator__.validate_python(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for Model
age
Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='Unknown', input_type=str]
For further information visit https://errors.pydantic.dev/2.5/v/int_parsing
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cydantic-0.1.0.tar.gz
(6.4 kB
view details)
Built Distribution
File details
Details for the file cydantic-0.1.0.tar.gz
.
File metadata
- Download URL: cydantic-0.1.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.2 Linux/5.10.189-1-MANJARO
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | abbcefa3649ebbe8289728eb09837ff65379e84003f1211bc4bfec2aa8a616ce |
|
MD5 | 13ce2d1a1a6554de7211f6523384c380 |
|
BLAKE2b-256 | c741bf89441f9ccd5873924d159f3eb151549d8a806f8101ed76d22e4d5c9f8b |
File details
Details for the file cydantic-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: cydantic-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.2 Linux/5.10.189-1-MANJARO
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 803050e7a7da07d1126f5fbe98fe758de4354b3cd1544d79c3a8e238dfabde6c |
|
MD5 | 8a8b5d993527091219328c97ce25834b |
|
BLAKE2b-256 | 2e65b7b0041d033b412c7b6bbad5a0bc40bafe0a90bc611e9bc373b27992296b |