Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_dbmodel_core-0.0.3.tar.gz (9.9 kB view hashes)

Uploaded Source

Built Distribution

pydantic_dbmodel_core-0.0.3-py3-none-any.whl (8.9 kB view hashes)

Uploaded Python 3

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