ets-labs / python-dependency-injector

Dependency injection framework for Python
https://python-dependency-injector.ets-labs.org/
BSD 3-Clause "New" or "Revised" License
3.99k stars 305 forks source link

Auto wiring #823

Open sparky2708 opened 1 month ago

sparky2708 commented 1 month ago

Is there a way to auto-wire?

e.g.:

class B: @inject def init(self, registered_class: IRegisteredClass): ...

Why do I need to specify Provider[...]. If all are wired why not just auto-wire IRegisteredClass interface to the object that is registered in some container that implements this interface?

LeOndaz commented 1 month ago

If this seems viable for the author to have, I can PR this

I neither checked the code nor used the package, so the decision is mainly up to people who know it very well, I'm mainly looking to contribute in DI projects since I'm a fan of the pattern