Skip to content
/ potage Public

A simple Python package that provides an easy way to use Dependency Injection in your projects.

License

Notifications You must be signed in to change notification settings

pavalso/potage

Repository files navigation

pypotage

img img python-package-yml codecov

A simple Python package that provides an easy way to use Dependency Injection in your projects.

alt text

Key Features

  • Easy to use
  • Supports both function and class-based dependency injection
  • Allows customizing the way dependencies are resolved
  • Allows for the use of custom containers

Installing

To install the latest pypotage version, run the following command:

python -m pip install -U pypotage

Development

To install the development version:

git clone https://github.com/pavalso/potage.git
cd potage
python -m pip install -U .

Quick Examples

Basic usage

import pypotage
import logging

@pypotage.prepare
def logger():
    logging.basicConfig(level=logging.DEBUG)
    return logging.getLogger(__name__)

pypotage.cook(logging.Logger).take_out().info("Hello World!")

Using classes

import pypotage

class A:
    def __init__(self):
        ...

@pypotage.prepare
class B(A):
    def __init__(self):
        ...

pypotage.cook(A).take_out()  # returns an instance of B