python-dependency-injector
python-dependency-injector copied to clipboard
Dependency injection framework for Python
Hi all. As per the subject, we use dependency injector in one of our services. Part of the setup phase is to connect to the database and initialise all the...
When `container.init_resources()` is called, it is expected that resources are loaded in the same order every time (and ideally in a way that can be controlled, but that is outside...
As python 3.12 RC is released and a release is planned in 1.5months, I like to report in advance that there are issues with installing dependency-injector. On mac, `pip install...
* Ignore .vscode * Python 3.12 Support * Change base python to 3.12 and pin pydantic to V1 * all tests passed * ci: change default python to 3.12 *...
``` └─> py.test giphynavigator/tests.py --cov=giphynavigator =============================================================================================== test session starts ================================================================================================ platform darwin -- Python 3.10.13, pytest-7.4.4, pluggy-1.3.0 rootdir: /Users/I530566/devel/mine/hamradio/tmp/python-dependency-injector plugins: asyncio-0.23.3, cov-4.1.0, anyio-4.2.0 asyncio: mode=strict collected 3 items giphynavigator/tests.py FFF...
```py import dependency_injector.containers as dic import dependency_injector.providers as dip class UnitOfWork: ... class TestUnitOfWork(UnitOfWork): ... class ApplicationContainer(dic.DeclarativeContainer): unit_of_work_class = dip.Callable(UnitOfWork) uow = dip.Factory(unit_of_work_class) class TestApplicationContainer(ApplicationContainer): unit_of_work_class = dip.Callable(TestUnitOfWork) container =...
Is there a way to wire a function instead of wiring an entire module?
In pydantic 2.0+ the `BaseSettings` class has been moved into a optional package, pydantic-settings. The configuration provider's `from_pydantic` method expect to find it in the pydantic package: https://github.com/ets-labs/python-dependency-injector/blob/master/src/dependency_injector/providers.pyx#L1806-L1816 This results...
Using the object provider to store a pydantic model triggers a deprecation warning. ```python from dependency_injector.containers import DeclarativeContainer, WiringConfiguration from dependency_injector.providers import Object, Dependency from pydantic import BaseModel class MyObject(BaseModel):...
Is there a way to use type hints with `providers.Configuration`? Right now I'm loading config settings in with `from_env` or `from_yaml` then injecting them them using `Container.config.foo.bar`, but I don't...