Comments (5)
I created a gist with a minimal (not) working sample of what i tried. In case you don't know peewee
(a sql orm), the most important function in order to understand this gist should be engine.create_tables() which accepts an array of table classes, which it then creates in the database.
https://gist.github.com/romangraef/584f8c075143412dd0f681a5b189e440
from injectable.
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.
from injectable.
Thank you for the gist @romangraef. I've run it and it does give me an error due to the Type
wrapper. I've removed the Type
wrapper and just used tables: Autowired(typing.List[TableBase])
and it worked.
Sorry, I think that I didn't get it when you said you can't use Autowired(List[BaseType])
, especially the "no empty __init__
" thing. Can you clarify this for me?
from injectable.
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.
from injectable.
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 Type
. It is odd that one would want an object of type Type
and most probably typing.Type
isn't intended for that kind of usage.
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 python-injectable
tag.
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.
from injectable.
Related Issues (19)
- Lazy type class HOT 4
- Enable `@autowired` decorator to be called without parenthesis HOT 1
- Original function's signature overwrite
- Autowiring should be done without actually importing the dependency's class HOT 5
- Autowired(List[...]) does not work with qualifiers
- Using named args breaks injectable
- Optional injection doesn't work when there are the namespce is empty
- Evaluate the use of code scanning tools other than SonarQube
- Injectable fails to resolve entangled imports
- [Feature Request] Manually supplying injectables HOT 4
- [Bug] inject method signature accepts T instead of Type[T] HOT 1
- ImportError due to changes in 3.4.3 HOT 3
- No context is created when no injectables are found, attempt to put object - fails #triage @bug HOT 4
- Missing encoding in container injection HOT 2
- Official Support for Python 3.9 HOT 1
- First-class support for testing HOT 2
- Support for async injectables HOT 6
- Comply with PEP-593 and support typing.Annotated HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from injectable.