You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello Alec & open source contributors - I love this library - it feels very well designed and strikes a sweet spot between complexity / ease of use. However, I am running into a little bit of a snag and was wondering if anyone else came across this problem:
I currently have some helper provider modules that specify how to provide for a certain interface type (this is defined as a class member on modules that I wanted to bind DI to):
I dynamically load all modules and then add these to the provider container:
provider_containers= [config_provider]
# register all providersforcomponentincomponent_classes:
# all modules should implement this provider classasserthasattr(
component, "_ModuleProvider"
), "Component {} does not define a provider".format(component.__name__)
provider_containers.append(component._ModuleProvider())
# later oninjector=Injector(provider_containers, auto_bind=False) # note I disabled autobind herepipeline=injector.get(Pipeline)
However, some Pipeline implementations might have stricter requirements on the interface type so their constructor might take a DerivedType directly.
I currently work around this by declaring another provider
Hello Alec & open source contributors - I love this library - it feels very well designed and strikes a sweet spot between complexity / ease of use. However, I am running into a little bit of a snag and was wondering if anyone else came across this problem:
I currently have some helper provider modules that specify how to provide for a certain interface type (this is defined as a class member on modules that I wanted to bind DI to):
I dynamically load all modules and then add these to the provider container:
However, some
Pipeline
implementations might have stricter requirements on the interface type so their constructor might take aDerivedType
directly.I currently work around this by declaring another provider
But I was just wondering if it's possible to do this:
If there's a better way than what I was doing, I'd appreciate it too. Thank you!
The text was updated successfully, but these errors were encountered: