Injection of dependencies for python 3
Project description
A bag of objects for Python
For when your object graph is too big
class A:
def __init__(self, b: B):
self.b = b
class B:
pass
svc = {
'a': A,
'b': B,
}
context = Pytel(svc)
assert context.a.b == context.b
See usage for more cases
Features
Build a graph of objects based on init methods or factory functions
- Initialize from
- a dictionary of string to any of:
callable
type
value
- Object containing any of:
object fields with objects or types (or callables)
class fields with objects or types (or callables)
methods
static methods
An Iterable of the above
Verify integrity of the dependency graph using type annotations
Recurrently resolve all dependencies at the first reference
Works as a Context Manager, on __exit__ close all objects that are Context Managers
Because of strict type checking this package is probably quite unpythonic.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pytel-inject-0.5.tar.gz
(8.4 kB
view hashes)
Built Distribution
Close
Hashes for pytel_inject-0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49e677affc7ce6366df035118a206deac0e63b589776b5a08a11bd992900dcf8 |
|
MD5 | d783b7e568012f30e8eeaa8a85c78f5f |
|
BLAKE2b-256 | 56ad62997a4ca15ae3dc0f01b5d4053c093337d4adadf369cc249f1cbcf9779d |