No project description provided
Project description
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
- 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
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
Close
Hashes for extendable_pydantic-0.0.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | def4ade4198422724648c9280431add496e4d7752525afd697e08ebc8e7f1872 |
|
MD5 | 9c9fa798c7248ef05478441fa92e280c |
|
BLAKE2b-256 | 8bfeb1e6ab1891c21033b20b21797fa6727c6c9ba09449787a3a451abc800188 |
Close
Hashes for extendable_pydantic-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90d1fe8517dd180f47847a94071db45b15d6562f979d577df1b545f7e2d795a1 |
|
MD5 | 1645fa36fb1ef169c9ac4a37506d54a3 |
|
BLAKE2b-256 | ca6b17c50283cd1888f53052216ddcfbd242f4bc26f8ebaee0fd8f8d91319b96 |