Browse Source

Fix linting

pull/10147/head
Mix 2 years ago
parent
commit
a10a186c88
  1. 4
      fastapi/security/http.py
  2. 6
      fastapi/security/utils.py

4
fastapi/security/http.py

@ -66,7 +66,9 @@ class HTTPBasic(HTTPBase):
self.auto_error = auto_error self.auto_error = auto_error
@handle_exc_for_ws @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") authorization = request.headers.get("Authorization")
scheme, param = get_authorization_scheme_param(authorization) scheme, param = get_authorization_scheme_param(authorization)
if self.realm: if self.realm:

6
fastapi/security/utils.py

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

Loading…
Cancel
Save