pieceful 0.3.1

Last updated:

0 purchases

pieceful 0.3.1 Image
pieceful 0.3.1 Images
Add to Cart

Description:

pieceful 0.3.1

Pieceful


Description
Pieceful is a Python package that provides a collection of utility functions for working with dependency injection.
Installation
Install with
pip install pieceful

Features

TODO

Usage
First perform necessary import:
from typing import Annotated
from pieceful import Piece, PieceFactor, get_piece

Than decorate your dependencies with Piece or PieceFactory decorator and name your dependencies.
class Engine:
pass

class PowerfulEngine(Engine):
pass

@PieceFactory("powerful_engine")
def powerful_engine_factory() -> Engine:
return PowerfulEngine()

class AbstractVehicle:
pass

@Piece("car")
class Car(AbstractVehicle):
def __init__(self, engine: Annotated[Engine, "powerful_engine"]):
self.engine = engine

When components are registered (with decorators in this case) they can be injected to other components (like Engine -> Car) by using typing.Annotated or they can be directly obtained.
car = get_piece("car", Car)

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.