Skip to content

Commit d7734de

Browse files
author
Joel Collins
committed
Renamed tasks dict to fix PYL-W0622
1 parent 587e2a0 commit d7734de

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

labthings/core/tasks/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
__all__ = [
22
"taskify",
33
"tasks",
4-
"dict",
4+
"dictionary",
55
"states",
66
"current_task",
77
"update_task_progress",
@@ -13,7 +13,7 @@
1313

1414
from .pool import (
1515
tasks,
16-
dict,
16+
dictionary,
1717
states,
1818
current_task,
1919
update_task_progress,

labthings/core/tasks/pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def tasks():
6767
return DEFAULT_TASK_MASTER.tasks
6868

6969

70-
def dict():
70+
def dictionary():
7171
"""
7272
Dictionary of tasks in default taskmaster
7373
Returns:

labthings/server/views/tasks.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,29 @@ def get(self):
1818
@Tag(["properties", "tasks"])
1919
class TaskView(View):
2020
@marshal_with(TaskSchema())
21-
def get(self, id):
21+
def get(self, task_id):
2222
"""
2323
Show status of a session task
2424
2525
Includes progress and intermediate data.
2626
"""
27-
try:
28-
task = tasks.dict()[id]
29-
except KeyError:
27+
28+
task = tasks.dictionary().get(task_id)
29+
if not task:
3030
return abort(404) # 404 Not Found
3131

3232
return task
3333

3434
@marshal_with(TaskSchema())
35-
def delete(self, id):
35+
def delete(self, task_id):
3636
"""
3737
Terminate a running task.
3838
3939
If the task is finished, deletes its entry.
4040
"""
41-
try:
42-
task = tasks.dict()[id]
43-
except KeyError:
41+
42+
task = tasks.dictionary().get(task_id)
43+
if not task:
4444
return abort(404) # 404 Not Found
4545

4646
task.terminate()

0 commit comments

Comments
 (0)