Skip to content

Commit b68ffc0

Browse files
fix mypy
1 parent cc6470f commit b68ffc0

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

services/director-v2/src/simcore_service_director_v2/api/errors/http_error.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
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)
11+
1012
return JSONResponse(
1113
content=jsonable_encoder({"errors": [exc.detail]}), status_code=exc.status_code
1214
)
@@ -22,7 +24,7 @@ def make_http_error_handler_for_exception(
2224
SEE https://docs.python.org/3/library/exceptions.html#concrete-exceptions
2325
"""
2426

25-
async def _http_error_handler(_: Request, exc: type[BaseException]) -> JSONResponse:
27+
async def _http_error_handler(_: Request, exc: Exception) -> JSONResponse:
2628
assert isinstance(exc, exception_cls) # nosec
2729
return JSONResponse(
2830
content=jsonable_encoder({"errors": [str(exc)]}), status_code=status_code

services/director-v2/src/simcore_service_director_v2/api/errors/validation_error.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212

1313
async def http422_error_handler(
1414
_: Request,
15-
exc: Union[RequestValidationError, ValidationError],
15+
exc: Exception,
1616
) -> JSONResponse:
17+
assert isinstance(exc, RequestValidationError | ValidationError)
18+
1719
return JSONResponse(
1820
content=jsonable_encoder({"errors": exc.errors()}),
1921
status_code=HTTP_422_UNPROCESSABLE_ENTITY,

services/director-v2/src/simcore_service_director_v2/core/errors.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ class WalletNotEnoughCreditsError(OsparcErrorMixin, DirectorError):
129129

130130

131131
class SchedulerError(DirectorError):
132-
code = "scheduler_error"
133-
134132
def __init__(self, msg: str | None = None):
135133
super().__init__(msg or "Unexpected error in the scheduler")
136134

@@ -144,6 +142,7 @@ def __init__(self, pipeline_id: str, msg: str | None = None):
144142

145143
class TaskSchedulingError(SchedulerError):
146144
"""A task cannot be scheduled"""
145+
code: str = "task scheduler error"
147146

148147
def __init__(self, project_id: ProjectID, node_id: NodeID, msg: str | None = None):
149148
super().__init__(msg=msg)
@@ -225,12 +224,12 @@ def get_errors(self) -> list[ErrorDict]:
225224

226225

227226
class ComputationalSchedulerChangedError(OsparcErrorMixin, SchedulerError):
228-
code = "computational_backend.scheduler_changed"
227+
code = "computational_backend.scheduler_changed" # type: ignore
229228
msg_template = "The dask scheduler ID changed from '{original_scheduler_id}' to '{current_scheduler_id}'"
230229

231230

232231
class ComputationalBackendNotConnectedError(OsparcErrorMixin, SchedulerError):
233-
code = "computational_backend.not_connected"
232+
code = "computational_backend.not_connected" # type: ignore
234233
msg_template = "The dask computational backend is not connected"
235234

236235

@@ -239,24 +238,24 @@ class ComputationalBackendNoS3AccessError(OsparcErrorMixin, SchedulerError):
239238

240239

241240
class ComputationalBackendTaskNotFoundError(OsparcErrorMixin, SchedulerError):
242-
code = "computational_backend.task_not_found"
241+
code = "computational_backend.task_not_found" # type: ignore
243242
msg_template = (
244243
"The dask computational backend does not know about the task '{job_id}'"
245244
)
246245

247246

248247
class ComputationalBackendTaskResultsNotReadyError(OsparcErrorMixin, SchedulerError):
249-
code = "computational_backend.task_result_not_ready"
248+
code = "computational_backend.task_result_not_ready" # type: ignore
250249
msg_template = "The task result is not ready yet for job '{job_id}'"
251250

252251

253252
class ClustersKeeperNotAvailableError(OsparcErrorMixin, SchedulerError):
254-
code = "computational_backend.clusters_keeper_not_available"
253+
code = "computational_backend.clusters_keeper_not_available" # type: ignore
255254
msg_template = "clusters-keeper service is not available!"
256255

257256

258257
class ComputationalBackendOnDemandNotReadyError(OsparcErrorMixin, SchedulerError):
259-
code = "computational_backend.on_demand_cluster.not_ready"
258+
code = "computational_backend.on_demand_cluster.not_ready" # type: ignore
260259
msg_template = (
261260
"The on demand computational cluster is not ready 'est. remaining time: {eta}'"
262261
)
@@ -266,7 +265,7 @@ class ComputationalBackendOnDemandNotReadyError(OsparcErrorMixin, SchedulerError
266265
# SCHEDULER/CLUSTER ERRORS
267266
#
268267
class ClusterNotFoundError(OsparcErrorMixin, SchedulerError):
269-
code = "cluster.not_found"
268+
code = "cluster.not_found" # type: ignore
270269
msg_template = "The cluster '{cluster_id}' not found"
271270

272271

@@ -284,24 +283,24 @@ class ClusterInvalidOperationError(OsparcErrorMixin, SchedulerError):
284283

285284

286285
class DaskClientRequestError(OsparcErrorMixin, SchedulerError):
287-
code = "dask_client.request.error"
286+
code = "dask_client.request.error" # type: ignore
288287
msg_template = (
289288
"The dask client to cluster on '{endpoint}' did an invalid request '{error}'"
290289
)
291290

292291

293292
class DaskClusterError(OsparcErrorMixin, SchedulerError):
294-
code = "cluster.error"
293+
code = "cluster.error" # type: ignore
295294
msg_template = "The dask cluster on '{endpoint}' encountered an error: '{error}'"
296295

297296

298297
class DaskGatewayServerError(OsparcErrorMixin, SchedulerError):
299-
code = "gateway.error"
298+
code = "gateway.error" # type: ignore
300299
msg_template = "The dask gateway on '{endpoint}' encountered an error: '{error}'"
301300

302301

303302
class DaskClientAcquisisitonError(OsparcErrorMixin, SchedulerError):
304-
code = "dask_client.acquisition.error"
303+
code = "dask_client.acquisition.error" # type: ignore
305304
msg_template = (
306305
"The dask client to cluster '{cluster}' encountered an error '{error}'"
307306
)

services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ class LegacyServiceIsNotSupportedError(DirectorError):
4040

4141

4242
class UnexpectedContainerStatusError(OsparcErrorMixin, DynamicSidecarError):
43-
code = "dynamic_sidecar.container_status"
43+
code = "dynamic_sidecar.container_status" # type: ignore
4444
msg_template = "Unexpected status from containers: {containers_with_error}"

0 commit comments

Comments
 (0)