Detect where __call__
is async def
in context of iscoroutinefunction()
#123
Labels
Bug 🐛
This is something that is not working as expected
My use-case is basically a guard that I create with some state:
@put(guards=[CheckPayloadMismatch("id", "user_id").__call__])
Without passing through the
__call__()
method, starlite tries to call the instance sync.As of
0.20.1
, starlette themselves include this utility:And a handful of test cases: https://github.com/encode/starlette/blob/master/tests/test__utils.py
Based on a quick search, there are 6 separate usages of
iscoroutinefunction()
: https://github.com/starlite-api/starlite/search?q=iscoroutinefunction. The most complex pattern of use is:https://github.com/starlite-api/starlite/blob/f9893f28bc210e032e0527a61a6b695fc9e5c801/starlite/handlers/asgi.py#L43
Which would collapse down to a single call to
is_async_callable()
if we adopt such a function.I'm happy to do the work if you give it the green light.
The text was updated successfully, but these errors were encountered: