Skip to main content

Pydantic Fabricated

A Python package that provides a metaclass for fabricating subclasses from dictionaries inside Pydantic models. This library seamlessly integrates with Pydantic's type system to enable dynamic object creation based on type definitions.

Installation

pip install pydantic-fabricated

Features

  • Dynamic object creation from type definitions
  • Seamless integration with Pydantic models
  • Type-safe parameter validation
  • Support for JSON serialization/deserialization
  • Discriminated unions for type-safe polymorphism

Quick Start

Here's a simple example of how to use Pydantic Fabricated:

import os

from pydantic_settings import BaseSettings, SettingsConfigDict

from pydantic_fabricated import PydanticFabricated


# Define a base class using the metaclass
class Shape(metaclass=PydanticFabricated):
    pass


# Define concrete implementations
class Circle(Shape):
    def __init__(self, radius: float):
        self.radius = radius


class Rectangle(Shape):
    def __init__(self, width: float, height: float):
        self.width = width
        self.height = height


# Create instances using the fabricate_from_type method
circle = Shape.fabricate_from_type('Circle', {'radius': 5.0})
rectangle = Shape.fabricate_from_type('Rectangle', {'width': 10.0, 'height': 20.0})


# Or use with Pydantic Settings
class Settings(BaseSettings):
    model_config = SettingsConfigDict(env_prefix='my_prefix_')

    shape: Shape


os.environ['MY_PREFIX_SHAPE'] = r'{"type": "Circle", "radius": 5.0}'
settings = Settings()

Requirements

  • Python ≥ 3.13
  • Pydantic ≥ 2.11.9

License

Apache License 2.0

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Additional Documentation

Metadata

Release files for pydantic-fabricated 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydantic-fabricated 1.1.0
File Size Uploaded Provenance
pydantic_fabricated-1.1.0.tar.gz 82.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pydantic-fabricated 1.1.0
File Interpreter ABI Platform
pydantic_fabricated-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 92.9 kB

Release files / pydantic_fabricated-1.1.0.tar.gz

Download URL pydantic_fabricated-1.1.0.tar.gz
Size 82.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2893b01909e96eecc2479388d72408126e311a716fd109f1b9ccb6cb28d51ef1
BLAKE2b-256 checksum
How to use checksums
ca336aebb735333992864b4ab9d8193748f65f664a0d2f5034463bf5ff0f852c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / pydantic_fabricated-1.1.0-py3-none-any.whl

Download URL pydantic_fabricated-1.1.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5ff201dc2c41d1bd9aced48407d1b3b3f9342fd1f15cc081207e3952298ecb0
BLAKE2b-256 checksum
How to use checksums
4622b02e08ba9df4d17d579b3175a063d7dd11d4846a43bc14aa6e056d81188d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Security for pydantic-fabricated 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pydantic_fabricated-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page