Skip to main content

pyderive

PyPI version Python versions License: MIT Made with Love

Python3 Custom Dataclass Helpers

Installation

pip install pyderive3

Features

Additional Features availalbe via Extensions.

Expanded Reimplementation of Dataclasses
Default Standards Implemented

'slots' kwarg now supported in older versions of python such as 3.8

from pyderive import *

@dataclass
class Foo:
    bar: int

@dataclass(slots=True, order=True)
class Bar(Foo):
    foo: str

bar = Bar(foo='foo', bar=100)
print(asdict(bar))
Recursive Field Compilation
from pyderive import *
from typing import Optional

class Foo:
    bar: int

@dataclass(recurse=True)
class Bar(Foo):
    foo: Optional[str] = None

bar = Bar(foo='foo', bar=100)
print(bar)
Allow for Custom Field Definitions
from pyderive import *
from typing import Any

@dataclass
class NewField(BaseField):
    custom_attr: bool = False

def field(*_, **kwargs) -> Any:
    return NewField(**kwargs)

@dataclass(field=NewField)
class Foo:
    a: int
    b: str = field(default='b', repr=False, custom_attr=True)

foo = Foo(1, 'boo')
print(foo)

for f in fields(foo):
    print(f.name, f.custom_attr)
Backwards Compatibility
import pyderive
import dataclasses

@dataclasses.dataclass
class Foo:
    a: int
    b: int = dataclasses.field(repr=False)

@pyderive.dataclass
class Bar(Foo):
    c: int = pyderive.field(frozen=True)

f = Bar(1, 2, 3)
print(f)
Monkey Patching
from pyderive import compat
compat.monkey_patch()

from dataclasses import dataclass, field

@dataclass
class Foo:
    a: int
    b: int = field(frozen=True)

f = Foo(1, 2)
print(f)
Low Level Dataclass Compilation Tools
from pyderive import *

class Foo:
    foo: int

class Bar(Foo):
    bar: int = 100

# parse class-structure into raw unordered heigharhcy
struct = parse_fields(Bar, recurse=True)
print('struct', struct)

# order and structure fields into organized list following dataclass standard
fields = flatten_fields(struct)
print('final_fields', fields)

# build and assign `init` and `repr` functions to `Bar` class
assign_func(Bar, create_init(fields))
assign_func(Bar, create_repr(fields))

# assign slots for field definitions onto `Bar` class
Bar = add_slots(Bar, fields)
print(Bar.__slots__)

# initialize foo w/ compiled `init` func and print w/ added `repr`
bar = Bar(foo=1, bar=2)
print(bar)

Metadata

Release files for pyderive3 0.0.9

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

Source distribution (sdist)

Source distribution for pyderive3 0.0.9
File Size Uploaded Provenance Actions
pyderive3-0.0.9.tar.gz 44.5 kB Without provenance Details for pyderive3-0.0.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyderive3 0.0.9
File Interpreter ABI Platform Actions
pyderive3-0.0.9-py3-none-any.whl Python 3 none any Details for pyderive3-0.0.9-py3-none-any.whl

Total release size: 96.3 kB

Release files / pyderive3-0.0.9.tar.gz

Download URL pyderive3-0.0.9.tar.gz
Size 44.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0b4013e99f6f3908918677ec8130ced7817d0d8a9c5e969fce0bf4a716ba4d00
BLAKE2b-256 checksum
How to use checksums
ec62c5b2447614fe3cabfcc8c97298e086d4aa3a66946aaaf167197836f20b1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / pyderive3-0.0.9-py3-none-any.whl

Download URL pyderive3-0.0.9-py3-none-any.whl
Size 51.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
73cde3a20b04d199325b4add7c0af5fff5ab6779d414eee32a1acf0695ba2566
BLAKE2b-256 checksum
How to use checksums
3e9d60846fea72ae958791fc5c5e194c1f3715ae9f9a5aaa9687f4dcb144603c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for pyderive3 0.0.9

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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