(middleware: Iterable[MiddlewareInput])
| 83 | |
| 84 | |
| 85 | def validate_sync_middleware(middleware: Iterable[MiddlewareInput]) -> None: |
| 86 | for entry in middleware: |
| 87 | if isinstance(entry, Middleware): |
| 88 | if type(entry).handle is Middleware.handle: |
| 89 | raise TypeError( |
| 90 | f"middleware {_middleware_name(entry)} does not implement `handle()`; " |
| 91 | "the synchronous client requires sync-capable middleware" |
| 92 | ) |
| 93 | if inspect.iscoroutinefunction(type(entry).handle): |
| 94 | raise TypeError( |
| 95 | f"middleware {_middleware_name(entry)} defines `handle()` as an async function; " |
| 96 | "the synchronous client requires `handle()` to be a sync function" |
| 97 | ) |
| 98 | elif not callable(entry): |
| 99 | raise TypeError(f"middleware {_middleware_name(entry)} is not callable") |
| 100 | elif _is_async_callable(entry): |
| 101 | raise TypeError( |
| 102 | f"middleware {_middleware_name(entry)} is an async function; " |
| 103 | "the synchronous client requires sync middleware functions" |
| 104 | ) |
| 105 | |
| 106 | |
| 107 | def validate_async_middleware(middleware: Iterable[MiddlewareInput]) -> None: |
no test coverage detected