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.0.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.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pieceful-0.3.0.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.0.tar.gz
Algorithm Hash digest
SHA256 17e7f7d2c392e2de2bd7425b49b4c01da9a43867566ec55ebc06dd60c45f7d8a
MD5 979ba3859bc23c0b14a8b58e6536e632
BLAKE2b-256 fcc0161b3f3e4e9d24b245f1fdce6620b91a7f1537c234dc3de7abcc8d13b9c7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pieceful-0.3.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 237ef2b92431ee5b622c573d99f63670fdf46d2d73902201791fcbadd505f203
MD5 1c48435d7b4254d3849d2a4b3b3c78a6
BLAKE2b-256 9d9cc9f655808a3778c745798c6ddbd7fb0cb1a00688d0f7ebeea0e83c884afc

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