Skip to main content

Simple python package to solve dependency injections

Project description

Pieceful

License Python Version

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pieceful-0.2.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pieceful-0.2.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file pieceful-0.2.1.tar.gz.

File metadata

  • Download URL: pieceful-0.2.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-25-generic

File hashes

Hashes for pieceful-0.2.1.tar.gz
Algorithm Hash digest
SHA256 87981a9f690b215b6fb84b3bc2ace2f856b6993d62c581129c5df7833400c278
MD5 a7e4c56b31e1840dee8cb017eba52a1b
BLAKE2b-256 3da13410beba2e8d100b56537169e4155eb0d8c069cfd3180b06d866ca93579b

See more details on using hashes here.

File details

Details for the file pieceful-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pieceful-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-25-generic

File hashes

Hashes for pieceful-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cb22b8f1c51d822cdc0744541069a111fb2f60ce794b8199f8e8ebba2508ba32
MD5 c7f38ad3f12d7e0221e6a9cfce2bb00c
BLAKE2b-256 268542a0ccde3cb6021d320df69cef157b4d61d7879149a066acf0158f6d1d63

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page