Skip to main content

No project description provided

Project description

CI codecov

pydantic-ext

This addons provides a new type used to declare Pydantic model as Extendable class.

from pydantic import BaseModel
from extendable_pydantic import ExtendableModelMeta
from extendable import context, registry

class Location(BaseModel, metaclass=ExtendableModelMeta):
    lat = 0.1
    lng = 10.1

class ExtendedLocation(Location, extends=Location):
    name: str

_registry = registry.ExtendableClassesRegistry()
context.extendable_registry.set(_registry)
_registry.init_registry()

loc = Location(**{"lat": 12.3, "lng": 13.2, "name": "My Loc"})

loc.dict() == {"lat": 12.3, "lng": 13.2, "name": "My Loc"}
#> True

loc.schema()
#> {'title': 'Location', 'type': 'object', 'properties': {'lat': {'title': 'Lat', 'default': 0.1, 'type': 'number'}, 'lng': {'title': 'Lng', 'default': 10.1, 'type': 'number'}, 'name': {'title': 'Name', 'type': 'string'}}, 'required': ['name']}

Development

pip install -e .

Then, copy extendable_pydantic_patcher.pth to $VIRTUAL_ENV/lib/python3.10/site-packages.

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

extendable_pydantic-0.0.3.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

extendable_pydantic-0.0.3-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file extendable_pydantic-0.0.3.tar.gz.

File metadata

  • Download URL: extendable_pydantic-0.0.3.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for extendable_pydantic-0.0.3.tar.gz
Algorithm Hash digest
SHA256 cac18e374e5fda82d0b448c2f727c1d6a8cf646bdaea148f67ebc70817825529
MD5 2889179344cf2d710dff074130205cc8
BLAKE2b-256 2397aff5beaf1345e6182d19c922ce817f791d3ca86a18601f5b33d355afeeb3

See more details on using hashes here.

File details

Details for the file extendable_pydantic-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for extendable_pydantic-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 981ab7e0d31240a7addc41a4b1e262c4d24929dbd23df5e24d3fbe9ad4f3dd87
MD5 9eaad9825a02a750b7b4ee631a54ed6b
BLAKE2b-256 a9c6c8d35a6a9ff894d282f4fbe229f5e8f86149c33035eb37ca6c4b6c8104d6

See more details on using hashes here.

Supported by

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