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
See https://haps.readthedocs.io/en/latest/
See https://github.com/lunarwings/haps/tree/master/samples
Install requirements.test.txt
and run py.test
in main directory.
- Add
>>
operator - Add
DI
alias UpdateRemove.travis.yml
- Setup GitHub actions
- Fix bug with optional arguments for functions decorated with
@inject
- Add configuration module
- Add application class and runner
- Add profiles
- Minor fixes
@egg
decorator can be used without function invocation
- Add support for python 3.7
- Fix autodiscover sample
- First stable release