python-dependency-injector icon indicating copy to clipboard operation
python-dependency-injector copied to clipboard

Strict Mode / Better Errors when dependency is missing

Open genixpro opened this issue 9 months ago • 1 comments

I've been using this library for a while, and its great. I am often using strings to reference my dependencies, e.g. Provide['stuff']. And I have different application containers that support different configurations of applications.

Right now, if I forget a key dependency for a specific container, I end up getting an error that looks like this:

AttributeError: 'Provide' object has no attribute 'get_by_user_id'

This is because DI could not find the dependency. I would rather that the DI framework itself just threw a more descriptive error, e.g. "XYZ Dependency Not Found"

genixpro avatar Apr 26 '24 14:04 genixpro

In my eyes it would be even better to raise an error while wiring so it breaks python process while analysing code for places to inject deps. Otherwise you will get this feedback while executing specific code.

kamilglod avatar Aug 05 '24 09:08 kamilglod