Giter Club home page Giter Club logo

Comments (5)

nea89o avatar nea89o commented on May 19, 2024 1

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.

roo-oliv avatar roo-oliv commented on May 19, 2024

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.

roo-oliv avatar roo-oliv commented on May 19, 2024

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.

nea89o avatar nea89o commented on May 19, 2024

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.

roo-oliv avatar roo-oliv commented on May 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.