Skip to content

Commit 399461c

Browse files
authored
Merge pull request #334 from ynput/enhancement/change-assignees-to-set
Entity hub: Use set for assignees
2 parents d678aa1 + e71f2b6 commit 399461c

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

‎ayon_api/entity_hub.py‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ class ProjectStatusDict(TypedDict):
5656
scope: NotRequired[Optional[StatusEntityType]]
5757

5858

59+
class Assignees(set):
60+
"""Helper class for task assignees.
61+
62+
Assignees used to be a list and 'append' is being used a lot.
63+
"""
64+
def append(self, item: str) -> None:
65+
self.add(item)
66+
67+
5968
class _CustomNone:
6069
def __init__(self, name: Optional[str] = None) -> None:
6170
self._name = name or "CustomNone"
@@ -3430,9 +3439,9 @@ def __init__(
34303439
entity_hub=entity_hub,
34313440
)
34323441
if assignees is None:
3433-
assignees = []
3442+
assignees = Assignees()
34343443
else:
3435-
assignees = list(assignees)
3444+
assignees = Assignees(assignees)
34363445

34373446
self._task_type = task_type
34383447
self._assignees = assignees
@@ -3463,11 +3472,11 @@ def set_task_type(self, task_type: str) -> None:
34633472

34643473
task_type = property(get_task_type, set_task_type)
34653474

3466-
def get_assignees(self) -> list[str]:
3475+
def get_assignees(self) -> Assignees[str]:
34673476
"""Task assignees.
34683477
34693478
Returns:
3470-
list[str]: Task assignees.
3479+
Assignees[str]: Task assignees.
34713480
34723481
"""
34733482
return self._assignees
@@ -3479,7 +3488,7 @@ def set_assignees(self, assignees: Iterable[str]) -> None:
34793488
assignees (Iterable[str]): assignees.
34803489
34813490
"""
3482-
self._assignees = list(assignees)
3491+
self._assignees = Assignees(assignees)
34833492

34843493
assignees = property(get_assignees, set_assignees)
34853494

@@ -3497,7 +3506,7 @@ def changes(self) -> dict[str, Any]:
34973506
changes["taskType"] = self._task_type
34983507

34993508
if self._orig_assignees != self._assignees:
3500-
changes["assignees"] = self._assignees
3509+
changes["assignees"] = list(self._assignees)
35013510

35023511
return changes
35033512

@@ -3549,7 +3558,7 @@ def to_create_body_data(self) -> dict[str, Any]:
35493558
output["tags"] = self.tags
35503559

35513560
if self.assignees:
3552-
output["assignees"] = self.assignees
3561+
output["assignees"] = list(self.assignees)
35533562

35543563
if self._data is not UNKNOWN_VALUE:
35553564
output["data"] = self._data.get_new_entity_value()

0 commit comments

Comments
 (0)