Enabling the coexistence of class variables and instance variables with identical names on Pydantic
Project description
Pydantic DbModel Core
Overview
The pydantic-dbmodel-core
library presents the DbModelCore
class, an augmentation of the BaseModel
class from Pydantic. This enhancement is achieved through a change in the ModelMetaclass
meta-class, enabling the coexistence of class variables and instance variables with identical names. This feature, available in Pydantic V1 but absent in Pydantic V2, has been reintroduced with this small yet crucial modification.
Installation
To install pydantic-dbmodel-core
, run the following command:
pip install pydantic-dbmodel-core
Usage
Import the DbModelCore
class from the library and use it as you would use Pydantic's BaseModel
.
from pydantic_dbmodel_core import DbModelCore
class YourModel(DbModelCore):
# Define your fields here
pass
Features
- Allows the definition of class variables with the same name as instance variables.
- Fully compatible with Pydantic's field definitions and validators.
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
File details
Details for the file pydantic_dbmodel_core-0.0.3.tar.gz
.
File metadata
- Download URL: pydantic_dbmodel_core-0.0.3.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c782eda08484079d841220b0472d77836637b67c15a94a9b2a1057722ea96c62 |
|
MD5 | 8762b79343558a18f7872ab531abb5f1 |
|
BLAKE2b-256 | 9eb9e56281d8f845424712667f1ffa0e3fc2045e9e6afe8ab9a21c9735a723ed |
File details
Details for the file pydantic_dbmodel_core-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: pydantic_dbmodel_core-0.0.3-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9524def9945aeee0ddb3f34c7e7baa0e2bfb01aaf3bc89c146538df00447f419 |
|
MD5 | b30bef9249ca6219819e06438a444d74 |
|
BLAKE2b-256 | 68a04b8f009a068d3faf7dbfad342b634a59ac4dfc3d306a75a516d06aea395f |