Closed
Description
I found that providers.Dependency
is not recognizing falsy default value as any provided value, which failbacks to raising errors due to missing dependency definition.
Simplest test case that works without errors:
default = {'foo': 'bar'}
provider = providers.Dependency(instance_of=dict, default=default)
self.assertEqual(provider(), default)
But on falsy default value it complaints about no dependency defined:
default = {}
provider = providers.Dependency(instance_of=dict, default=default)
self.assertEqual(provider(), default) # Raises dependency_injector.errors.Error: Dependency is not defined
I'm expecting that any provided default value will be accepted and used when no explicit value is passed to providers.Dependency
. I'm using dependency_injector
version of 4.37.0
.