Fix linting

This commit is contained in:
Mix 2023-08-26 15:17:30 +08:00 committed by HexMix
parent 70a48e59a2
commit 7d071df243
2 changed files with 6 additions and 4 deletions

View File

@ -187,7 +187,9 @@ class HTTPBasic(HTTPBase):
self.auto_error = auto_error
@handle_exc_for_ws
async def __call__(self, request: HTTPConnection) -> Optional[HTTPBasicCredentials]:
async def __call__( # type: ignore
self, request: HTTPConnection
) -> Optional[HTTPBasicCredentials]:
authorization = request.headers.get("Authorization")
scheme, param = get_authorization_scheme_param(authorization)
if self.realm:

View File

@ -17,15 +17,15 @@ def get_authorization_scheme_param(
_SecurityDepFunc = TypeVar(
"_SecurityDepFunc", bound=Callable[[Any, HTTPConnection], Awaitable]
"_SecurityDepFunc", bound=Callable[[Any, HTTPConnection], Awaitable[Any]]
)
def handle_exc_for_ws(func: _SecurityDepFunc) -> _SecurityDepFunc:
@wraps(func)
async def wrapper(self, request: HTTPConnection, *args, **kwargs):
async def wrapper(self: Any, request: HTTPConnection) -> Any:
try:
return await func(self, request, *args, **kwargs)
return await func(self, request)
except HTTPException as e:
if not isinstance(request, WebSocket):
raise e