Skip to main content

Simple DI Library

Project description

haps PyPI Build Status

Haps [χaps] is a simple DI library, with IoC container included. It is written in pure Python with no external dependencies.

Look how easy it is to use:

from haps import Container as IoC, Inject, inject

# import interfaces
from my_application.core import IDatabase, IUserService

class MyApp:
    db: IDatabase = Inject()  # dependency as a property

    @inject  # or passed to the constructor
    def __init__(self, user_service: IUserService) -> None:
        self.user_service = user_service

IoC.autodiscover('my_application')  # find all interfaces and implementations

if __name__ == '__main__':
    app = MyApp()
    assert isinstance(app.db, IDatabase)
    assert isinstance(app.user_service, IUserService)


pip install haps



Usage examples



Install requirements.test.txt and run py.test in main directory.


1.1.1 (2018-07-27)

  • Fix bug with optional arguments for functions decorated with @inject

1.1.0 (2018-07-26)

  • Add configuration module
  • Add application class and runner
  • Add profiles
  • Minor fixes

1.0.5 (2018-07-12)

  • @egg decorator can be used without function invocation

1.0.4 (2018-06-30)

  • Add support for python 3.7
  • Fix autodiscover sample

1.0.0 (2018-06-15)

  • First stable release

Project details

Download files

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

Files for haps, version 1.1.2
Filename, size File type Python version Upload date Hashes
Filename, size haps-1.1.2-py3-none-any.whl (16.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size haps-1.1.2.tar.gz (12.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page