Closed igorbenav closed 7 months ago
Both approaches are acceptable in my opinion, but I would personally prefer the former (without Depends). Let me just define what dependency is required and make the library handle it for me as needed. That's also less verbose.
Also note that in the newest version of tiangolo fastapi template it's not required to wrap the deps with Depends in route parameters. He leverages Dependency annotations instead. Maybe we could support both cases, by conditionally wraping deps when needed?
Just noticed I wrote what was here on the wrong place
Also note that in the newest version of tiangolo fastapi template it's not required to wrap the deps with Depends in route parameters.
Yeah, this would definitely be a more elegant approach, but it's still more work to the user.
Maybe we could support both cases, by conditionally wraping deps when needed?
I think we should pick something and stick to it, support it in the best possible way. One flexibility we could allow is:
We get a sequence of functions, each function might have a type hint, if it does, we use the dependency annotation with the custom type, if not, we do it with Callable
.
Describe the bug or question In the docs, we have something like
When actually the correct way would be:
I'd like some opinion if possible on whether we should fix the docs or change the way it works. The latter is more explicit, but I think the former might be simpler for the end user.
If the former is used, stuff like getting non-callable objects or dependencies that are already wrapped must be handled.