Registry / serialization / lazr-delegates

lazr-delegates

JSON →
library2.1.1pypypiunverified

lazr.delegates provides a simple, declarative way to create Python objects that delegate behavior to other objects. It simplifies the implementation of common design patterns like composition, allowing classes to expose methods from 'delegatee' objects without boilerplate code. The current version is 2.1.1, and the library maintains a stable, albeit infrequent, release cadence, primarily focusing on Python compatibility and bug fixes.

pip install lazr-delegates
INSTALL
IMPORT
SIG · LAZR-DELEGATES
L
lazr-delegates
serializationpythonv2.1.1
Install
2.1s avg
Import
Disk
22MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.1s · import 0.000s · 21MB
22MB installed
● package 22MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

delegates
from lazr.delegates import delegates
from lazr.delegates import delegates

This example demonstrates how to use the `@delegates` decorator to easily expose methods from another class. `MyPet` delegates `make_sound` and `get_animal_type` to an instance of `SoundMaker` implicitly.

from lazr.delegates import delegates class SoundMaker: def make_sound(self): return "Woof!" def get_animal_type(self): return "Dog" @delegates(SoundMaker) class MyPet: # MyPet now delegates make_sound and get_animal_type to SoundMaker pass pet = MyPet() print(f"Pet sound: {pet.make_sound()}") print(f"Pet type: {pet.get_animal_type()}")
Debug
Known issues
breakingVersion 2.0.0 dropped support for Python 2.x and Python 3.7. The library now requires Python 3.8 or newer.
fix
Ensure your project's Python environment is 3.8 or higher. If you need older Python support, use `lazr-delegates<2.0.0` (e.g., 1.0.3 for Python 3.7, 1.0.2 for Python 2.7).
affects: >=2.0.0
gotchaBy default, `lazr.delegates` primarily delegates methods. If you intend to delegate attributes (properties, instance variables), you need to explicitly configure the delegate type.
fix
Set `_DelegateType.delegated_attributes = True` on a custom delegate type, or pass `delegated_attributes=True` when defining the delegate type for `delegates`.
affects: All
gotchaWhen combining `lazr.delegates` with complex inheritance hierarchies, particularly multiple inheritance or explicit `super()` calls, method resolution order (MRO) can lead to unexpected behavior.
fix
Carefully design your class hierarchy. For complex cases, explicitly define the MRO if possible, or consider using custom `DelegateType` classes to control how methods are looked up and invoked. Test thoroughly with `inspect.getmro()`.
affects: All
Upgrade
Version history
2.1.1latest on PyPI · released Dec 5, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
lazr-delegates — pip install lazr-delegates · libregistry