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.

Release

  • Tag the sources: git tag x.y.z
  • Build the package: hatch build
  • Publish to pypi: twine upload dist/*

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.5.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

extendable_pydantic-0.0.5-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: extendable_pydantic-0.0.5.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for extendable_pydantic-0.0.5.tar.gz
Algorithm Hash digest
SHA256 8c1c07caadeb270574621c713b3c219b7d737d90b0b1a2477355a20b530b9bff
MD5 a7fd2e9bfae7b3676c7fae724db7abc9
BLAKE2b-256 e383a9beb52de2b8c33abdf95577118cbd4e48d95469bf170d54b4842b3d07ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for extendable_pydantic-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c19e03f6526158b9dc65541d6fcf3578955735b53eb6c038bb80ef176f39cb7b
MD5 64b93dfb52b4a7a6ca80418334ece9b5
BLAKE2b-256 8c8599ddf7eb1a324139fec6d05ce1bca8e06f130cc2c487f16fb3a820be3017

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