pyderive
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.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyderive3-0.0.8.tar.gz | 43.2 kB | Without provenance | Details for pyderive3-0.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyderive3-0.0.8-py3-none-any.whl | Python 3 | none | any | Details for pyderive3-0.0.8-py3-none-any.whl |
Total release size: 94.6 kB
Release files / pyderive3-0.0.8.tar.gz
| Download URL | pyderive3-0.0.8.tar.gz |
|---|---|
| Size | 43.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ce8c8690a10957c657635a6329e1c9a48382722c54eefbacdf84d1b61ef63f6
|
|
BLAKE2b-256 checksum How to use checksums |
9fb2e1a1b5189271d8ac0ae6c37186bdaabb33cadc2d5421855e29f737e0b4cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.8.20
|
Release files / pyderive3-0.0.8-py3-none-any.whl
| Download URL | pyderive3-0.0.8-py3-none-any.whl |
|---|---|
| Size | 51.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
edba3257a709fc2e911caf1e2214633a8583c46fa6aece604e232f4c29663664
|
|
BLAKE2b-256 checksum How to use checksums |
86d7af8b71eb978f7e256ba22e16750bb91cd3e034b38e31e65420a48b2c7f9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.8.20
|
Security for pyderive3 0.0.8
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.