Skip to content

Commit

Permalink
API, Task processing: fix ruff linting errors E721
Browse files Browse the repository at this point in the history
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()`
```
  • Loading branch information
DavidB137 committed Aug 24, 2023
1 parent 01d2965 commit b68d008
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 1 addition & 4 deletions dp3/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions dp3/task_processing/task_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit b68d008

Please sign in to comment.