python-dependency-injector
python-dependency-injector copied to clipboard
Specializing the provided type using `Provider[T]` syntax
trafficstars
Hi, recently I found out that it's possible to specialize the provided type using Provider[T] syntax. For example:
from abc import ABC
from dependency_injector import containers, providers
class AbstractClass(ABC): ...
class ImplementationClass(AbstractClass): ...
class Container(containers.DeclarativeContainer):
service = providers.Singleton[AbstractClass](ImplementationClass)
Is this way of specializing type considered supported and is it a part of public API? If so, could you add this information to the documentation? I haven't been able to find any mention there.