Giter Club home page Giter Club logo

Comments (2)

davidbrochart avatar davidbrochart commented on June 21, 2024 1

Thanks for looking into it @tlambert03, I think the workaround is simple enough for now.

from in-n-out.

tlambert03 avatar tlambert03 commented on June 21, 2024

yeah, I don't think this one is going to be possible, but i think it's more of a typer limitation than in-n-out, and I don't think there's anything (safe) we could do to help it along.

if I'm not mistaken, typer just doesn't support custom types? tiangolo/typer#77
so, as you no doubt found, removing in-n-out altogether from the example still gives the Type not yet supported error when typer encounters thing: Thing in the signature.

The very best we could do (and I don't like it) is to patch the __signature__ attribute of an in-n-out injected function to essentially remove injected types from the signature, so that typer simply doesn't see them when it inspects signatures here: https://github.com/tiangolo/typer/blob/50caff27573e0d1381701d24122ca9fed20d6343/typer/main.py#L548

... the problem with that is

  1. it's a lie: the parameters are still in the signature, and in-n-out does allow you to pass them to the function if you wish to override injection when calling the function.
  2. we actually don't know which parameters will be injected (at injection time). we only know it at call time (since providers can be registered at any point, even after decorating a function with ino.inject). So, even if we wanted to remove something, we wouldn't know it was thing that needed to be removed.

Since typer is its own dependency injection system, this one is probably going to be tough to pull off. but perhaps if tiangolo/typer#77 is addressed, we could extend support for it

from in-n-out.

Related Issues (20)

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.