Dependency Injector 3.19 has been released - New Selector provider

I have released Dependency Injector 3.19.

This release adds Selector provider. Release also fixes minor bug in Configuration provider.

Release is available for downloads on PyPI.

Selector provider

Selector provider selects provider based on the configuration value or other callable.

The idea of Selector provider was brought up at the issue #239. It was brought up by Markus Leuthold (githubkusi). Thanks to Markus for his contribution.

from dependency_injector import providers

class SomeClass:

class SomeOtherClass:

config = providers.Configuration()

selector = providers.Selector(

config.override({'one_or_another': 'one'})
instance_1 = selector()
assert isinstance(instance_1, SomeClass)

config.override({'one_or_another': 'another'})
instance_2 = selector()
assert isinstance(instance_2, SomeOtherClass)


Enjoy Python and Dependency Injector.