Simple DI Library
Project description
haps
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)
Installation
pip install haps
Documentation
See https://haps.readthedocs.io/en/latest/
Usage examples
See https://github.com/lunarwings/haps/tree/master/samples
Testing
Install requirements.test.txt
and run py.test
in main directory.
Changelog
1.1.3 (2022-02-04)
- Add
>>
operator - Add
DI
alias - Update
.travis.yml
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
haps-1.1.3.tar.gz
(12.8 kB
view details)
Built Distribution
haps-1.1.3-py3-none-any.whl
(17.0 kB
view details)
File details
Details for the file haps-1.1.3.tar.gz
.
File metadata
- Download URL: haps-1.1.3.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03797570d3698df17848a7198659edcb478d5ec4746ef42348725697e3d90e2b |
|
MD5 | de2053a702684df1c332f851136a1d22 |
|
BLAKE2b-256 | 866ba05adf5b6165c181c0d08b4356d523410fcaa78c9f1a803ba1846fd8d03d |
File details
Details for the file haps-1.1.3-py3-none-any.whl
.
File metadata
- Download URL: haps-1.1.3-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 623f8668b93854fc893b533e2a8aba54baa42bb3f68d78ba586140c9d67599ca |
|
MD5 | ab5e7f9f2f3c116228ca3c5bb33fe78c |
|
BLAKE2b-256 | dfb45436f867b6d05400c98cfcc4e1029d9eadb00f0df8a1c452d44d5146dab1 |