-
-
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
Making typing.Type injectable. #28
Comments
Hi @romangraef! Thank you for the issue with implementation suggestions details Could you provide a minimal working example of how you're using injectable today? I fear I wasn't fully able to see it through. With a concrete example, it will be easier to spot the issue's root cause and think of the best way out of it. |
I created a gist with a minimal (not) working sample of what i tried. In case you don't know https://gist.github.com/romangraef/584f8c075143412dd0f681a5b189e440 |
Thank you for the gist @romangraef. I've run it and it does give me an error due to the Sorry, I think that I didn't get it when you said you can't use |
Hmm, i thought you couldn't instantiate the tables objects without arguments, but i might have been wrong. Well that saved me that trouble, and I'm sorry for yours. It might still be an interesting feature to be able to inject the Type instead, but (as i said in my OP) there probably aren't that many use cases except for this specific one. |
Injectables mustn't depend on mandatory arguments. In case arguments are needed for instantiation one should declare an injectable_factory to correctly instantiate objects. Currently, I don't see a real benefit in allowing wrapping types with I'm really glad that you solved your issue 🎉 Please, feel free to open other issues if you find it necessary or to post a question at StackOverflow with the As the issue seems solved I'm closing it. If you believe that it should be reopened just leave a comment and I'll review it. |
Introduction
I am currently into an issue where i need the Type of all
@injectable
objects. These objects have a common supertype, but no empty__init__
, so I can't just useAutowired(List[BaseType])
. Concrete, this is a database project, and the model classes need to be registered so they can be created in the database.This is kinda far fetched, and i could definitely see why this would be rejected, as database models are kind of the only usecase i coud think of, and it is kind of narrow.
Feature Request
Allowing the
Autowired(Type[BaseType])
to pick up an injectable subclass of aBaseType
, orAutowired(List[Type[BaseType]])
to get all injectable subclasses. Maybe this could be indicated by@injectable(type=True)
.By submiting an issue I accept this project's
Code of Conduct. Any issue out of
these guidelines can be deleted at any moment without further explanation.
The text was updated successfully, but these errors were encountered: