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.1

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.1
File Size Uploaded Provenance
pydantic_fabricated-1.1.1.tar.gz 84.1 kB With provenance Details

Built distribution (wheel)

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

Total release size: 94.6 kB

Release files / pydantic_fabricated-1.1.1.tar.gz

Download URL pydantic_fabricated-1.1.1.tar.gz
Size 84.1 kB
Tags Source
SHA-256 checksum
How to use checksums
386817f8e7acc9cb802c20600447dbfac0410f2c9cf884b05b8eaeacbeda8a5a
BLAKE2b-256 checksum
How to use checksums
efe656cf4f148dcfb8c868bccd61986813329ede4ec52ed545248e435047e331
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 24, 2026.

Transparency log

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

Download URL pydantic_fabricated-1.1.1-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebed994bdbdc959235511336d0e1af2cf685116795ddb299b87ca3e047783f76
BLAKE2b-256 checksum
How to use checksums
ee2bc92c809d56a72e035403dbdd26a1df19dd2fa62091d3dd828df5c11509e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 24, 2026.

Transparency log

Security for pydantic-fabricated 1.1.1

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.1.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 24, 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