Skip to content

Commit a993b18

Browse files
committed
fixed mypy
1 parent c25a365 commit a993b18

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

services/datcore-adapter/src/simcore_service_datcore_adapter/api/errors/http_error.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
from typing import Callable, Optional
1+
from typing import Callable
22

33
from fastapi import HTTPException
44
from fastapi.encoders import jsonable_encoder
55
from starlette.requests import Request
66
from starlette.responses import JSONResponse
77

88

9-
async def http_error_handler(_: Request, exc: HTTPException) -> JSONResponse:
9+
async def http_error_handler(_: Request, exc: Exception) -> JSONResponse:
10+
assert isinstance(exc, HTTPException) # nosec
1011
return JSONResponse(
1112
content=jsonable_encoder({"errors": [exc.detail]}), status_code=exc.status_code
1213
)
@@ -16,7 +17,7 @@ def make_http_error_handler_for_exception(
1617
status_code: int,
1718
exception_cls: type[BaseException],
1819
*,
19-
override_detail_message: Optional[str] = None,
20+
override_detail_message: str | None = None,
2021
) -> Callable:
2122
"""
2223
Produces a handler for BaseException-type exceptions which converts them

services/datcore-adapter/src/simcore_service_datcore_adapter/api/errors/pennsieve_error.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77

88
async def botocore_exceptions_handler(
99
_: Request,
10-
exc: ClientError,
10+
exc: Exception,
1111
) -> JSONResponse:
12+
assert isinstance(exc, ClientError) # nosec
13+
assert "Error" in exc.response # nosec
14+
assert "Code" in exc.response["Error"] # nosec
1215
if exc.response["Error"]["Code"] == "NotAuthorizedException":
1316
return JSONResponse(
1417
content=jsonable_encoder({"errors": exc.response["Error"]}),

services/datcore-adapter/src/simcore_service_datcore_adapter/api/errors/validation_error.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Union
2-
31
from fastapi.encoders import jsonable_encoder
42
from fastapi.exceptions import RequestValidationError
53
from fastapi.openapi.constants import REF_PREFIX
@@ -12,8 +10,9 @@
1210

1311
async def http422_error_handler(
1412
_: Request,
15-
exc: Union[RequestValidationError, ValidationError],
13+
exc: Exception,
1614
) -> JSONResponse:
15+
assert isinstance(exc, RequestValidationError | ValidationError) # nosec
1716
return JSONResponse(
1817
content=jsonable_encoder({"errors": exc.errors()}),
1918
status_code=HTTP_422_UNPROCESSABLE_ENTITY,

0 commit comments

Comments
 (0)