Injector.py
A guide to implementing injector.py revolves around three main abstractions:
Instantiate the Injector and use it to retrieve your root object. injector.py
from injector import inject class Database: def __init__(self): self.status = "Connected" class Service: @inject def __init__(self, db: Database): self.db = db Use code with caution. Copied to clipboard A guide to implementing injector
Use type hints to declare what a class needs. The framework uses these hints to "look up" the correct dependency. The framework uses these hints to "look up"
: Use the @provider decorator inside a Module for more complex object creation that requires logic.
: The central orchestrator that builds the dependency graph and provides objects to your application. 3. Basic Implementation Guide Step A: Define Your Classes
For further details, consult the official Injector documentation . Make Your Django Project Less Confusing with Design Pattern