Skip to content

Conversation

@tiangolo
Copy link
Member

@tiangolo tiangolo commented Dec 3, 2025

🐛 Fix support for functools wraps and partial combined, for async and regular functions and classes in path operations and dependencies

This also uses and extends the tests created by @YuriiMotov 🙌

Should fix / related to: #14444

The new tests simulate the multiple combinations of how decorators could affect dependencies and path operation functions (endpoints).

The logic to analyze if a function is an async, generator, async generator, callable instance, etc. now also checks and unwraps and extracts partials in all those levels.

The main case is when the callable is an async something (function, generator, etc) because then it needs to be awaited.

But the original function could be async or not, the wrapper could be async or not. if either is async, then it has to be awaited, no matter if the other is not async. So, analyzing only the last point in the chain is not enough, it's necessary to analyze the function but also the wrapper.

This PR implements and tests all that, all those combinations.

@tiangolo tiangolo added the bug Something isn't working label Dec 4, 2025
@tiangolo tiangolo marked this pull request as ready for review December 4, 2025 02:17
@tiangolo tiangolo merged commit bba4d4c into master Dec 4, 2025
32 checks passed
@tiangolo tiangolo deleted the fix-coroutine-detection-for-wrapped-callable branch December 4, 2025 07:29
@tiangolo
Copy link
Member Author

tiangolo commented Dec 4, 2025

This is now released in FastAPI 0.123.6 🎉

@tirkarthi
Copy link

Thanks @tiangolo for the quick fix and release.

@potiuk
Copy link

potiuk commented Dec 4, 2025

Thanks a LOT! That was super quick :)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants