Whether calling the given object returns a coroutine. Unlike `inspect.iscoroutinefunction(obj)` this also handles class instances that define an async `__call__` method.
(obj: object)
| 71 | |
| 72 | |
| 73 | def _is_async_callable(obj: object) -> bool: |
| 74 | """Whether calling the given object returns a coroutine. |
| 75 | |
| 76 | Unlike `inspect.iscoroutinefunction(obj)` this also handles class instances |
| 77 | that define an async `__call__` method. |
| 78 | """ |
| 79 | if inspect.iscoroutinefunction(obj): |
| 80 | return True |
| 81 | call = getattr(obj, "__call__", None) # noqa: B004 |
| 82 | return call is not None and inspect.iscoroutinefunction(call) |
| 83 | |
| 84 | |
| 85 | def validate_sync_middleware(middleware: Iterable[MiddlewareInput]) -> None: |
no outgoing calls
no test coverage detected