Answer stability round 1: 0 🔴, 4 🟡 (0 misread); a cycle's close takes the task from the cycle, a resolved thread is skipped unread, and tests run git in their own environment
CI / tests (pull_request) Successful in 3m56s
CI / tests (pull_request) Successful in 3m56s
This commit is contained in:
+12
-7
@@ -148,15 +148,14 @@ def waiting_threads(number: str, run: Run) -> list[str] | Failure:
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Thread:
|
||||
"""One review thread of a pull request."""
|
||||
"""One review thread of a pull request that nobody resolved."""
|
||||
path: str
|
||||
resolved: bool
|
||||
# Who wrote its last comment; empty for a thread without one.
|
||||
last: tuple[str, ...]
|
||||
|
||||
|
||||
def threads_read(printed: str) -> tuple[str, tuple[Thread, ...]] | Failure:
|
||||
"""Who opened the pull request and its review threads, as gh printed THREADS' answer, with each field checked here."""
|
||||
"""Who opened the pull request and its review threads that nobody resolved, as gh printed THREADS' answer, with each field checked here."""
|
||||
unshaped = Failure(f"gh api graphql printed no review threads: {printed.strip()[:200]}")
|
||||
try:
|
||||
pull = held(json.loads(printed), "data", "repository", "pullRequest")
|
||||
@@ -167,16 +166,22 @@ def threads_read(printed: str) -> tuple[str, tuple[Thread, ...]] | Failure:
|
||||
return unshaped
|
||||
threads = []
|
||||
for thread in nodes:
|
||||
path, resolved, comments = held(thread, "path"), held(thread, "isResolved"), held(thread, "comments", "nodes")
|
||||
if not isinstance(path, str) or resolved is MISSING or not isinstance(comments, list):
|
||||
resolved = held(thread, "isResolved")
|
||||
if resolved is MISSING:
|
||||
return unshaped
|
||||
# A resolved thread is skipped unread: its last comment may be a deleted account's, whose author gh prints as null.
|
||||
if resolved:
|
||||
continue
|
||||
path, comments = held(thread, "path"), held(thread, "comments", "nodes")
|
||||
if not isinstance(path, str) or not isinstance(comments, list):
|
||||
return unshaped
|
||||
last = tuple(login for comment in comments if isinstance(login := held(comment, "author", "login"), str))
|
||||
if len(last) != len(comments):
|
||||
return unshaped
|
||||
threads.append(Thread(path, bool(resolved), last))
|
||||
threads.append(Thread(path, last))
|
||||
return author, tuple(threads)
|
||||
|
||||
|
||||
def waits(author: str, threads: tuple[Thread, ...]) -> list[str]:
|
||||
"""The files of the threads that wait for an answer from author, who opened the pull request."""
|
||||
return sorted({thread.path for thread in threads if not thread.resolved and any(last != author for last in thread.last)})
|
||||
return sorted({thread.path for thread in threads if any(last != author for last in thread.last)})
|
||||
|
||||
Reference in New Issue
Block a user