|
|
@ -1,4 +1,5 @@ |
|
|
|
import inspect |
|
|
|
import sys |
|
|
|
from contextlib import AsyncExitStack, contextmanager |
|
|
|
from copy import copy, deepcopy |
|
|
|
from dataclasses import dataclass |
|
|
@ -73,6 +74,11 @@ from starlette.responses import Response |
|
|
|
from starlette.websockets import WebSocket |
|
|
|
from typing_extensions import Annotated, get_args, get_origin |
|
|
|
|
|
|
|
if sys.version_info >= (3, 13): # pragma: no cover |
|
|
|
from inspect import iscoroutinefunction |
|
|
|
else: # pragma: no cover |
|
|
|
from asyncio import iscoroutinefunction |
|
|
|
|
|
|
|
multipart_not_installed_error = ( |
|
|
|
'Form data requires "python-multipart" to be installed. \n' |
|
|
|
'You can install "python-multipart" with: \n\n' |
|
|
@ -529,11 +535,11 @@ def add_param_to_fields(*, field: ModelField, dependant: Dependant) -> None: |
|
|
|
|
|
|
|
def is_coroutine_callable(call: Callable[..., Any]) -> bool: |
|
|
|
if inspect.isroutine(call): |
|
|
|
return inspect.iscoroutinefunction(call) |
|
|
|
return iscoroutinefunction(call) |
|
|
|
if inspect.isclass(call): |
|
|
|
return False |
|
|
|
dunder_call = getattr(call, "__call__", None) # noqa: B004 |
|
|
|
return inspect.iscoroutinefunction(dunder_call) |
|
|
|
return iscoroutinefunction(dunder_call) |
|
|
|
|
|
|
|
|
|
|
|
def is_async_gen_callable(call: Callable[..., Any]) -> bool: |
|
|
|