From 3f7979123396be3c05b913af24524a21f17f72c8 Mon Sep 17 00:00:00 2001 From: creatorrr Date: Fri, 4 Oct 2024 00:39:34 +0000 Subject: [PATCH] refactor: Lint agents-api (CI) --- .../agents_api/models/agent/create_agent.py | 20 +++++++++++++++---- .../models/agent/create_or_update_agent.py | 18 ++++++++++++++--- .../agents_api/models/agent/delete_agent.py | 20 +++++++++++++++---- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/agents-api/agents_api/models/agent/create_agent.py b/agents-api/agents_api/models/agent/create_agent.py index c1451bb30..a52a7b771 100644 --- a/agents-api/agents_api/models/agent/create_agent.py +++ b/agents-api/agents_api/models/agent/create_agent.py @@ -31,11 +31,23 @@ and "asserted to return some results, but returned none" in str(e): lambda *_: HTTPException( detail="Developer not found. Please ensure the provided auth token (which refers to your developer_id) is valid and the developer has the necessary permissions to create an agent.", - status_code=403 + status_code=403, + ), + QueryException: partialclass( + HTTPException, + status_code=400, + detail="A database query failed to return the expected results. This might occur if the requested resource doesn't exist or your query parameters are incorrect.", + ), + ValidationError: partialclass( + HTTPException, + status_code=400, + detail="Input validation failed. Please check the provided data for missing or incorrect fields, and ensure it matches the required format.", + ), + TypeError: partialclass( + HTTPException, + status_code=400, + detail="A type mismatch occurred. This likely means the data provided is of an incorrect type (e.g., string instead of integer). Please review the input and try again.", ), - QueryException: partialclass(HTTPException, status_code=400, detail="A database query failed to return the expected results. This might occur if the requested resource doesn't exist or your query parameters are incorrect."), - ValidationError: partialclass(HTTPException, status_code=400, detail="Input validation failed. Please check the provided data for missing or incorrect fields, and ensure it matches the required format."), - TypeError: partialclass(HTTPException, status_code=400, detail="A type mismatch occurred. This likely means the data provided is of an incorrect type (e.g., string instead of integer). Please review the input and try again."), } ) @wrap_in_class( diff --git a/agents-api/agents_api/models/agent/create_or_update_agent.py b/agents-api/agents_api/models/agent/create_or_update_agent.py index 17e01fccb..835245787 100644 --- a/agents-api/agents_api/models/agent/create_or_update_agent.py +++ b/agents-api/agents_api/models/agent/create_or_update_agent.py @@ -27,9 +27,21 @@ @rewrap_exceptions( { - QueryException: partialclass(HTTPException, status_code=400,detail="A database query failed to return the expected results. This might occur if the requested resource doesn't exist or your query parameters are incorrect."), - ValidationError: partialclass(HTTPException, status_code=400,detail="Input validation failed. Please check the provided data for missing or incorrect fields, and ensure it matches the required format."), - TypeError: partialclass(HTTPException, status_code=400,detail="A type mismatch occurred. This likely means the data provided is of an incorrect type (e.g., string instead of integer). Please review the input and try again."), + QueryException: partialclass( + HTTPException, + status_code=400, + detail="A database query failed to return the expected results. This might occur if the requested resource doesn't exist or your query parameters are incorrect.", + ), + ValidationError: partialclass( + HTTPException, + status_code=400, + detail="Input validation failed. Please check the provided data for missing or incorrect fields, and ensure it matches the required format.", + ), + TypeError: partialclass( + HTTPException, + status_code=400, + detail="A type mismatch occurred. This likely means the data provided is of an incorrect type (e.g., string instead of integer). Please review the input and try again.", + ), } ) @wrap_in_class( diff --git a/agents-api/agents_api/models/agent/delete_agent.py b/agents-api/agents_api/models/agent/delete_agent.py index d8f710481..c8bdc2106 100644 --- a/agents-api/agents_api/models/agent/delete_agent.py +++ b/agents-api/agents_api/models/agent/delete_agent.py @@ -31,11 +31,23 @@ and "Developer does not own resource" in e.resp["display"]: lambda *_: HTTPException( detail="The specified developer does not own the requested resource. Please verify the ownership or check if the developer ID is correct.", - status_code=404 + status_code=404, + ), + QueryException: partialclass( + HTTPException, + status_code=400, + detail="A database query failed to return the expected results. This might occur if the requested resource doesn't exist or your query parameters are incorrect.", + ), + ValidationError: partialclass( + HTTPException, + status_code=400, + detail="Input validation failed. Please check the provided data for missing or incorrect fields, and ensure it matches the required format.", + ), + TypeError: partialclass( + HTTPException, + status_code=400, + detail="A type mismatch occurred. This likely means the data provided is of an incorrect type (e.g., string instead of integer). Please review the input and try again.", ), - QueryException: partialclass(HTTPException, status_code=400,detail="A database query failed to return the expected results. This might occur if the requested resource doesn't exist or your query parameters are incorrect."), - ValidationError: partialclass(HTTPException, status_code=400,detail="Input validation failed. Please check the provided data for missing or incorrect fields, and ensure it matches the required format."), - TypeError: partialclass(HTTPException, status_code=400,detail="A type mismatch occurred. This likely means the data provided is of an incorrect type (e.g., string instead of integer). Please review the input and try again."), } ) @wrap_in_class(