Skip to content

Commit 87e2536

Browse files
committed
returns instead of raise
1 parent 3649da4 commit 87e2536

File tree

24 files changed

+44
-43
lines changed

24 files changed

+44
-43
lines changed

packages/service-library/src/servicelib/aiohttp/long_running_tasks/_routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async def cancel_and_delete_task(request: web.Request) -> web.Response:
8989
tasks_manager = get_tasks_manager(request.app)
9090
task_context = get_task_context(request)
9191
await tasks_manager.remove_task(path_params.task_id, with_task_context=task_context)
92-
raise web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
92+
return web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
9393

9494

9595
__all__: tuple[str, ...] = (
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from aiohttp import web
2+
from servicelib.mimetype_constants import MIMETYPE_APPLICATION_JSON
3+
4+
5+
def test_http_errors():
6+
7+
err = web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)

services/storage/src/simcore_service_storage/handlers_files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ async def abort_upload_file(request: web.Request) -> NoReturn:
261261

262262
dsm = get_dsm_provider(request.app).get(path_params.location_id)
263263
await dsm.abort_file_upload(query_params.user_id, path_params.file_id)
264-
raise web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
264+
return web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
265265

266266

267267
@routes.post(
@@ -386,7 +386,7 @@ async def delete_file(request: web.Request) -> NoReturn:
386386

387387
dsm = get_dsm_provider(request.app).get(path_params.location_id)
388388
await dsm.delete_file(query_params.user_id, path_params.file_id)
389-
raise web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
389+
return web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
390390

391391

392392
@routes.post(f"/{API_VTAG}/files/{{file_id}}:soft-copy", name="copy_as_soft_link")

services/storage/src/simcore_service_storage/handlers_simcore_s3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async def delete_folders_of_project(request: web.Request) -> NoReturn:
126126
query_params.node_id,
127127
)
128128

129-
raise web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
129+
return web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
130130

131131

132132
@routes.post(f"/{API_VTAG}/simcore-s3/files/metadata:search", name="search_files")

services/web/server/src/simcore_service_webserver/api_keys/_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ async def delete_api_key(request: web.Request):
8484
"Failed to delete API key %s. Ignoring error", name, exc_info=err
8585
)
8686

87-
raise web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
87+
return web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)

services/web/server/src/simcore_service_webserver/director_v2/_handlers.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,7 @@ async def stop_computation(request: web.Request) -> web.Response:
204204
await asyncio.gather(
205205
*[computations.stop(pid, req_ctx.user_id) for pid in project_ids]
206206
)
207-
208-
# NOTE: our middleware has this issue
209-
#
210-
# if 'return web.HTTPNoContent()' then 'await response.json()' raises ContentTypeError
211-
# if 'raise web.HTTPNoContent()' then 'await response.json() == None'
212-
#
213-
raise web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
207+
return web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
214208

215209
except DirectorServiceError as exc:
216210
return create_http_error(

services/web/server/src/simcore_service_webserver/folders/_folders_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,4 @@ async def delete_folder_group(request: web.Request):
246246
folder_id=path_params.folder_id,
247247
product_name=req_ctx.product_name,
248248
)
249-
raise web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
249+
return web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)

services/web/server/src/simcore_service_webserver/groups/_handlers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ async def delete_group(request: web.Request):
169169
path_params = parse_request_path_parameters_as(_GroupPathParams, request)
170170

171171
await api.delete_user_group(request.app, req_ctx.user_id, path_params.gid)
172-
raise web.HTTPNoContent
172+
return web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
173173

174174

175175
@routes.get(f"/{API_VTAG}/groups/{{gid}}/users", name="get_group_users")
@@ -215,7 +215,7 @@ async def add_group_user(request: web.Request):
215215
new_user_id=new_user_id,
216216
new_user_email=new_user_email,
217217
)
218-
raise web.HTTPNoContent
218+
return web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
219219

220220

221221
class _GroupUserPathParams(BaseModel):
@@ -275,7 +275,7 @@ async def delete_group_user(request: web.Request):
275275
await api.delete_user_in_group(
276276
request.app, req_ctx.user_id, path_params.gid, path_params.uid
277277
)
278-
raise web.HTTPNoContent
278+
return web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
279279

280280

281281
#

services/web/server/src/simcore_service_webserver/login/_registration_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ async def request_product_account(request: web.Request):
8585
task_suffix_name=f"{__name__}.request_product_account.send_account_request_email_to_support",
8686
fire_and_forget_tasks_collection=request.app[APP_FIRE_AND_FORGET_TASKS_KEY],
8787
)
88-
raise web.HTTPNoContent
88+
return web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
8989

9090

9191
class _AuthenticatedContext(BaseModel):

services/web/server/src/simcore_service_webserver/projects/_comments_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ async def delete_project_comment(request: web.Request):
223223
request=request,
224224
comment_id=path_params.comment_id,
225225
)
226-
raise web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
226+
return web.HTTPNoContent(content_type=MIMETYPE_APPLICATION_JSON)
227227

228228

229229
@routes.get(

0 commit comments

Comments
 (0)