Skip to main content

No project description provided

Project description

CI codecov

Extendable Pydantic

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

From release 1.0.0 it only supports Pydantic >= 2.0.0.

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.model_dump() == {"lat": 12.3, "lng": 13.2, "name": "My Loc"}
#> True

loc.model_json_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

  • run ``bumpversion patch|minor|major --list
  • Check the new_version value returned by the previous command
  • run towncrier build.
  • Inspect and commit the updated HISTORY.rst.
  • git tag {new_version} ; git push --tags.

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

Uploaded Source

Built Distribution

extendable_pydantic-1.4.1-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: extendable_pydantic-1.4.1.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for extendable_pydantic-1.4.1.tar.gz
Algorithm Hash digest
SHA256 c08b5e9a2a201d0f3b1dfda892059697d4c22cd9ee4d0c6fb3123a542b73a6e3
MD5 5a2691df9d69fdb95255380994210080
BLAKE2b-256 a50e734c08e4f20a8bf84eb22f407fd31ce5d84c0a6d793adfaa1c886554678f

See more details on using hashes here.

Provenance

The following attestation bundles were made for extendable_pydantic-1.4.1.tar.gz:

Publisher: release.yml on lmignon/extendable-pydantic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for extendable_pydantic-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 32051fe15378c63d37451e45d26ce88c2e76a073099d8eae85c524c48db3de39
MD5 25fe7be7369f900bef9ab6cc4e3b1550
BLAKE2b-256 f1f9f624594af61dfcc4facbd50e45a7919dcb100cdc9c5d7281f1c6b2b36d42

See more details on using hashes here.

Provenance

The following attestation bundles were made for extendable_pydantic-1.4.1-py3-none-any.whl:

Publisher: release.yml on lmignon/extendable-pydantic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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