From b68d008d46f9ffc373a1cbecc81485f4cdcba4b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Benko?= Date: Thu, 24 Aug 2023 08:21:17 +0000 Subject: [PATCH] API, Task processing: fix ruff linting errors `E721` Fixes errors from previous Github action: ``` Error: dp3/api/main.py:20:12: E721 Do not compare types, use `isinstance()` Error: dp3/api/main.py:20:38: E721 Do not compare types, use `isinstance()` Error: dp3/task_processing/task_hooks.py:96:20: E721 Do not compare types, use `isinstance()` Error: dp3/task_processing/task_hooks.py:157:20: E721 Do not compare types, use `isinstance()` ``` --- dp3/api/main.py | 5 +---- dp3/task_processing/task_hooks.py | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/dp3/api/main.py b/dp3/api/main.py index ed36e497..79b997d4 100644 --- a/dp3/api/main.py +++ b/dp3/api/main.py @@ -17,10 +17,7 @@ async def validation_exception_handler(request, exc): if request.url.path.replace(ROOT_PATH, "") == DATAPOINTS_INGESTION_URL_PATH: # Convert body to readable form - if type(exc.body) is dict or type(exc.body) is list: - body = json.dumps(exc.body) - else: - body = str(exc.body) + body = json.dumps(exc.body) if isinstance(exc.body, (dict, list)) else str(exc.body) DP_LOGGER.log_bad(body, str(exc), src=request.client.host) diff --git a/dp3/task_processing/task_hooks.py b/dp3/task_processing/task_hooks.py index 2a0c0ef5..974fe2b4 100644 --- a/dp3/task_processing/task_hooks.py +++ b/dp3/task_processing/task_hooks.py @@ -93,7 +93,7 @@ def run_on_creation(self, eid: str, task: DataPointTask): hook_new_tasks = hook(eid, task) # Append new tasks to process - if type(hook_new_tasks) is list: + if isinstance(hook_new_tasks, list): new_tasks += hook_new_tasks except Exception as e: self.elog.log("module_error") @@ -154,7 +154,7 @@ def run_on_new(self, eid: str, dp: DataPointBase): hook_new_tasks = hook(eid, dp) # Append new tasks to process - if type(hook_new_tasks) is list: + if isinstance(hook_new_tasks, list): new_tasks += hook_new_tasks except Exception as e: self.elog.log("module_error")