from starlette.responses import RedirectResponse, Response
from starlette.websockets import WebSocket
+_CallableType = typing.TypeVar("_CallableType", bound=typing.Callable)
+
def has_required_scope(conn: HTTPConnection, scopes: typing.Sequence[str]) -> bool:
for scope in scopes:
scopes: typing.Union[str, typing.Sequence[str]],
status_code: int = 403,
redirect: typing.Optional[str] = None,
-) -> typing.Callable:
+) -> typing.Callable[[_CallableType], _CallableType]:
scopes_list = [scopes] if isinstance(scopes, str) else list(scopes)
def decorator(func: typing.Callable) -> typing.Callable:
return sync_wrapper
- return decorator
+ return decorator # type: ignore[return-value]
class AuthenticationError(Exception):