Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_core_qpython-2.24.4.1.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_core_qpython-2.24.4.1-py3-none-any.whl (1.8 MB view details)

Uploaded Python 3

File details

Details for the file pydantic_core_qpython-2.24.4.1.tar.gz.

File metadata

File hashes

Hashes for pydantic_core_qpython-2.24.4.1.tar.gz
Algorithm Hash digest
SHA256 38f153d59ac3784916a06544a05085a9bc6cd5163f8893f1cfd30ad65a8b353f
MD5 db71551d47e6dddcddb90e5eaf5b2095
BLAKE2b-256 2005fba08507767c68d27aa6823e9bdd1f647660714ba94412ed7e3e9c783de9

See more details on using hashes here.

File details

Details for the file pydantic_core_qpython-2.24.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_core_qpython-2.24.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0f3986d73245c4cd0213e86157a7dd9a916fe560a46c615078f4778468ea928
MD5 be655e41b808662118a8ab9022a7d1b1
BLAKE2b-256 58be9574de16414cd5f470d95da59d85ab512863aa8f4e49e849033248d4b506

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page