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.3.1.tar.gz (4.8 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.3.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pieceful-0.3.1.tar.gz
  • Upload date:
  • Size: 4.8 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.3.1.tar.gz
Algorithm Hash digest
SHA256 499fa7cef3b8e12d9fe0118743d5164def2da86b0b2fa489ce8e82fd0796922c
MD5 f9c67e4425961fbddc43bd08eed11f7e
BLAKE2b-256 b927b52ab994be2baf788aa6d3b4df930271026bd1602b4974b2123ec6b0535d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pieceful-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 7.0 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.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6cdeba42ee6b97a1a61d9ce39682ba50689d578d6292339c06a0632db244ef1a
MD5 2dcacfb75da177156228221eb5715b3b
BLAKE2b-256 ceb72f0eaae293804d02478b4d0f6dc493944ee84d1a1db5ff2cf1d39a838036

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