It uses descriptors and decorators to reference external dependencies, and scopes to specify how to reuse objects.
Dependencies can be referenced by types and optional annotations.
No configuration is required, but advanced in-code configuration is possible.
Most other python dependency injection tools, such as PyContainer or Spring Python, are ports from other languages (Java). So they are based on dependency injection ways specific for statically typed languages.
Python is not Java, and so patterns and programming techniques, which seem proper and usable in one language, can be awkward in another.
Inject has been created to provide a pythonic way of dependency injection, utilizing specific Python functionality.
Terminology used in inject has been intentionally made similar to Guice, however the internal architecture is different.
Features:
- Fast, only 2-3 times slower that direct instantiation.
- Normal way of instantiating objects, Class(*args, **kwargs).
- Injecting arguments into functions and methods.
- Referencing dependencies by types and optional annotations.
- Binding to callables, instances and unbound methods (see [nvokers).
- Request scope middleware for WSGI and Django applications (requires Python2.5+).
- No configuration required at all.
- Advanced flexible configuration possible
- Two injection methods, a descriptor and a decorator
- Support for inheritance by passing inject.super as the default kwarg value
- Invokers to call unbound methods (cool for listeners)
- Partial injections, when only some arguments are injected:
- Scopes: application (singleton), request, noscope
- Easy integration into existing projects.
What is new in this release:
- Removed intelliJ idea files.
Comments not found