python-dependency-injector
python-dependency-injector copied to clipboard
TypeError: ClassName.__init__() got multiple values for argument 'argument_name' with upgrade to 4.41.0
trafficstars
Upon upgrading from 4.37.0 to 4.41.0 we now have failures throughout our test cases whenever we attempt to explicitly pass constructor arguments to a class wired up with dependency-injector for example:
class Container(containers.DeclarativeContainer):
config = providers.Configuration()
wiring_config = containers.WiringConfiguration(auto_wire=False)
logger = providers.Factory(
Logger.init_and_get_logger, module_name=config.logger.module_name, file=config.logger.file
)
class Foo:
@inject
def __init__(logger: BaseLogger = Provide[Container.logger])
self.logger = logger
class Test:
def test_foo():
mock_loger = MagicMock()
foo = Foo(mock_logger)
Now fails at the bottom line with Foo.init() got multiple values for argument 'argument_name'
Even more frustratingly, the failures appear to be non-deterministic. Occuring on some runs, but not on others.
Version: 4.41.0 Python version: Python 3.11.1 OS: MacOS 13.2.1 Hardware: Mac M1
I'm running into this too. If I use the config object, it runs into __init__ got multiple values
Did you ever figure this out?