Python >=3.6 dependency injection based on attrs. Very simple, yet powerful.
Inspired by inject-attrs.
deps
works only with typing annotations defined as presented below!
- First, replace your
@attr.s(...)
decorators: - With:
Notice that
auto_attribs=True
is no more needed, it will be forced by this package.- First, replace your
- Next you have to prepare - somewhere in your codebase - an abstract interfaces classes for your attributes:
- Now prepare interfaces implementations:
- Finally, configure dependency injection bindings provided by Inject package, using
bind_to_constructor
directive.
MIT
Daniel Kuruc