-
Notifications
You must be signed in to change notification settings - Fork 9
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
The case of multiple inheritance #48
Comments
The container only resolves the first parent class when registering a class. It should be possible to iterate over all bases and link all of them that are abstract with the current impl being registered. If you want to contribute that the relevant code is in For the current version you can just register A and B as regular services via factories and have the factory request and inject C instead. class A(ABC): ...
class B(ABC): ...
@service
class C(A, B): ...
@service
def a_factory(c: C) -> A:
return c
@service
def b_factory(c: C) -> B:
return c |
Thanks for the response. I tried factory solution already but I get the same error. Then I realised that I still kept @ abstract on A and B. Removing @ abstract made it work. Just dropping the note here in case somebody else gets hit by it. I'm hoping to contribute the feature soon with a PR. Many thanks again. |
Also FYI: In services you don't need to annotate dependencies with |
Hi,
I realised that it is not possible, as far as I can see, to inject a service which inherits multiple classes.
As C implements both A and B, I expect instance of C to be injected when either A or B is requested:
However, this does not seem to work:
I'm not sure if this is me doing something wrong or if this is an enhancement.
The text was updated successfully, but these errors were encountered: