Skip to content

Commit 2895da8

Browse files
committed
Work around mypy bug
1 parent 9970b4d commit 2895da8

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

services/web/server/src/simcore_service_webserver/functions/_functions_repository.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -891,21 +891,23 @@ async def check_exists(
891891
"""
892892
Checks if the object exists in the database.
893893
"""
894-
main_table = None
895-
error = None
896-
if object_type == "function":
897-
main_table = functions_table
898-
error = FunctionIDNotFoundError(function_id=object_id)
899-
elif object_type == "function_job":
900-
main_table = function_jobs_table
901-
error = FunctionJobIDNotFoundError(function_job_id=object_id)
902-
elif object_type == "function_job_collection":
903-
main_table = function_job_collections_table
904-
error = FunctionJobCollectionIDNotFoundError(
905-
function_job_collection_id=object_id
906-
)
907-
assert error is not None # nosec
908-
assert main_table is not None # nosec
894+
error: (
895+
FunctionIDNotFoundError
896+
| FunctionJobIDNotFoundError
897+
| FunctionJobCollectionIDNotFoundError
898+
) # This is to avoid mypy bug
899+
match object_type:
900+
case "function":
901+
main_table = functions_table
902+
error = FunctionIDNotFoundError(function_id=object_id)
903+
case "function_job":
904+
main_table = function_jobs_table
905+
error = FunctionJobIDNotFoundError(function_job_id=object_id)
906+
case "function_job_collection":
907+
main_table = function_job_collections_table
908+
error = FunctionJobCollectionIDNotFoundError(
909+
function_job_collection_id=object_id
910+
)
909911

910912
async with transaction_context(get_asyncpg_engine(app), connection) as conn:
911913
result = await conn.stream(

0 commit comments

Comments
 (0)