Answer stability round 1: 0 🔴, 1 🟡 (0 misread); split the re-rank into the pure rank_moves, rank only just before, as the item says, and name ranking in the README and the protocol
This commit is contained in:
@@ -7,7 +7,7 @@ from failure import Failure
|
||||
|
||||
@dataclasses.dataclass
|
||||
class MemoryEpic:
|
||||
"""An epic whose issues rank in the order filed, until one is ranked. Where fails is set, every call fails with it as the reason."""
|
||||
"""An epic whose issues rank in the order filed, until one is ranked. Where fails is set, every call but change fails with it as the reason."""
|
||||
epic_key: str
|
||||
issues: list[EpicIssue] = dataclasses.field(default_factory=list)
|
||||
fails: str | None = None
|
||||
@@ -39,14 +39,14 @@ class MemoryEpic:
|
||||
self.change(key, labels=tuple(sorted({*child.labels, label})))
|
||||
return None
|
||||
|
||||
def rank(self, key: str, other: str, after: bool = False) -> None | Failure:
|
||||
def rank(self, key: str, before: str) -> None | Failure:
|
||||
if self.fails:
|
||||
return Failure(self.fails)
|
||||
children = {issue.key: issue for issue in self.issues if issue.parent == self.epic_key}
|
||||
if stray := next((each for each in (key, other) if each not in children), None):
|
||||
return Failure(f"{stray} is not one of the child issues of the epic {self.epic_key}, so it cannot be ranked")
|
||||
if stray := next((each for each in (key, before) if each not in children), None):
|
||||
return Failure(f"{stray} is not one of the child issues of the epic {self.epic_key}, so {key} is not ranked")
|
||||
self.issues.remove(children[key])
|
||||
self.issues.insert(self.issues.index(children[other]) + after, children[key])
|
||||
self.issues.insert(self.issues.index(children[before]), children[key])
|
||||
return None
|
||||
|
||||
def change(self, key: str, **fields: object) -> None:
|
||||
|
||||
Reference in New Issue
Block a user