-
-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto wiring #823
Comments
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 |
I opened issues looking for some context on this specific question as I assumed it's something that can be done but I don't know how. |
I believe main reason is the fact that Python type system is different from Java-like ones. While technically you can achieve something similar to your suggestion, it falls apart when you have to deal with protocols, python generics, missing type info, etc... Python does have some notion of nominative type system to make this work, but still its dynamic nature makes it difficult to work with types in general. I was not here since project inception, but I've tried implementing my own DI solution once. I've abandoned the idea because loads of emerging edge cases using this approach.
So no, not now (given your definition of auto-wire). @dbarwacz If you need full decoupling, use |
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?
The text was updated successfully, but these errors were encountered: