Skip to main content

lazy

Python Utilities for the Super Lazy


Motivation

This library is forked from an internal project that works with a lot of dataclasses, (AWS API) and I got tired of writing data classes to work with and manipulate them. This library is a wrapper around the main pydantic.create_model function that recursively parses a dict object and transforms them into subclasses. So nested dict objects within dicts get transformed into their own dataclass.


Quickstart

pip install --upgrade lazycls
from lazycls import LazyCls, BaseLazy

data = {
    'x': ...,
    'y': ...
}

obj = LazyCls(
    name: str = 'CustomCls',
    data: Dict[str, Any] = data, 
    modulename: str = 'lazycls', # your module name
    basecls: Type[BaseModel] = BaseLazy # A custom Base Model class that is used to generate the model
    ) -> Type[BaseModel]:

"""
obj =   lazycls.CustomCls
        lazycls.CustomCls.x = ...
        lazycls.CustomCls.y = ...
"""

Utilities

Some additional enhancements/utilities include:

  • set_modulename(name) - set the default module name - useful when included in other libs

  • clear_lazy_models - clears all the currently created lazy models. Memory management

  • classproperty - allows for usage of @classproperty which isn't available for Python < 3.9

  • BaseCls - A wrapper around BaseModel with:

    • arbitrary_types_allowed = True
    • .get(name, default) function to retain dict-like properties
  • BaseLazy - Another wrapper around BaseModel with:

    • arbitrary_types_allowed = True
    • extra = 'allow'
    • alias_generator = to_camelcase
    • orjson serializer by default
    • .get(name, default) function to retain dict-like properties

Metadata

Release files for lazycls 0.1.15

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

Source distribution (sdist)

Source distribution for lazycls 0.1.15
File Size Uploaded Provenance Actions
lazycls-0.1.15.tar.gz 243.3 kB Without provenance Details for lazycls-0.1.15.tar.gz

Built distribution (wheel)

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

Total release size: 536.4 kB

Release files / lazycls-0.1.15.tar.gz

Download URL lazycls-0.1.15.tar.gz
Size 243.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b0900a7dd0b51d5d320a41a6b6e15c162c71ed13bbf8950ae84581d35bca5694
BLAKE2b-256 checksum
How to use checksums
592e0bfd257dbf0894c5ecb247146842a0232ae8dca67c44b87488519a86b6e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release files / lazycls-0.1.15-py3-none-any.whl

Download URL lazycls-0.1.15-py3-none-any.whl
Size 293.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de7cab079323ce8da46ee63d26f4d793fbceb6ccb9fae20c70d5303dcbf2dfb9
BLAKE2b-256 checksum
How to use checksums
c2e4bc2e4dd14732282674e106c9afa57f6c5cc551b2c62e89e06ca775208125
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Security for lazycls 0.1.15

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