This package provides the core functionality for pydantic validation and serialization
Project description
pydantic-core-qpython
This project is a branch of pydantic-core on QPython.
pydantic-core is one of the dependency library of langchain-qpython.
This package provides the core functionality for pydantic validation and serialization.
Pydantic-core is currently around 17x faster than pydantic V1. See tests/benchmarks/ for details.
Example of direct usage
NOTE: You should not need to use pydantic-core directly; instead, use pydantic, which in turn uses pydantic-core.
from pydantic_core import SchemaValidator, ValidationError
v = SchemaValidator(
{
'type': 'typed-dict',
'fields': {
'name': {
'type': 'typed-dict-field',
'schema': {
'type': 'str',
},
},
'age': {
'type': 'typed-dict-field',
'schema': {
'type': 'int',
'ge': 18,
},
},
'is_developer': {
'type': 'typed-dict-field',
'schema': {
'type': 'default',
'schema': {'type': 'bool'},
'default': True,
},
},
},
}
)
r1 = v.validate_python({'name': 'Samuel', 'age': 35})
assert r1 == {'name': 'Samuel', 'age': 35, 'is_developer': True}
# pydantic-core can also validate JSON directly
r2 = v.validate_json('{"name": "Samuel", "age": 35}')
assert r1 == r2
try:
v.validate_python({'name': 'Samuel', 'age': 11})
except ValidationError as e:
print(e)
"""
1 validation error for model
age
Input should be greater than or equal to 18
[type=greater_than_equal, context={ge: 18}, input_value=11, input_type=int]
"""
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydantic_core_qpython-2.24.4.1.tar.gz.
File metadata
- Download URL: pydantic_core_qpython-2.24.4.1.tar.gz
- Upload date:
- Size: 1.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38f153d59ac3784916a06544a05085a9bc6cd5163f8893f1cfd30ad65a8b353f
|
|
| MD5 |
db71551d47e6dddcddb90e5eaf5b2095
|
|
| BLAKE2b-256 |
2005fba08507767c68d27aa6823e9bdd1f647660714ba94412ed7e3e9c783de9
|
File details
Details for the file pydantic_core_qpython-2.24.4.1-py3-none-any.whl.
File metadata
- Download URL: pydantic_core_qpython-2.24.4.1-py3-none-any.whl
- Upload date:
- Size: 1.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0f3986d73245c4cd0213e86157a7dd9a916fe560a46c615078f4778468ea928
|
|
| MD5 |
be655e41b808662118a8ab9022a7d1b1
|
|
| BLAKE2b-256 |
58be9574de16414cd5f470d95da59d85ab512863aa8f4e49e849033248d4b506
|