Migration from Dependency Injector
If you have already used a wonderful package dependency-injector, then you probably know that there have been no new versions for a long time. It also lacks integration with FastAPI, for example to determine dependencies with Annotated (see issues). Injection package has an almost identical API to the dependency-injector and eliminates its shortcomings, which will make migrating very easy.
⚠️ IMPORTANT ❗
Injection does not implement some providers (List, Dict and etc.) because the developer considered them to be rarely used in practice. In this case, you don’t need to do the migration, but if you really want to use my package, I’d love to see your issues and/or merge requests!
To migrate, follow these steps:
Replace imports:
from dependency_injector import providers->from injection import providers;from dependency_injector.wiring import Provide, inject->from injection import Provide, inject;from dependency_injector.containers import DeclarativeContainer->from injection import DeclarativeContainer;
Replace argument unpacking in the
override_providersmethod call with direct argument passing:some_container.override_providers(**overrides)->some_container.override_providers(overrides);