This commit is contained in:
@@ -501,14 +501,14 @@ def missing_blocker(blockers: tuple[str, ...], held: set[object], label: str) ->
|
||||
|
||||
|
||||
def blocking_loop(answered: list[object], issue: Issue, blockers: tuple[str, ...], label: str) -> Failure | None:
|
||||
"""A Failure where issue, once blocked by blockers, would block itself through the items its blockers wait for, and none of them could be taken; None otherwise. A loop the plan already holds without issue isn't this edit's."""
|
||||
"""A Failure where issue, once blocked by blockers, which the caller has checked are open children, would block itself through the items its blockers wait for, and none of them could be taken; None otherwise. A loop the plan already holds without issue isn't this edit's."""
|
||||
issues = {found.key: found for raw in answered if isinstance(found := issue_of(raw), Issue)}
|
||||
waits_for = {found.key: found.blockers for found in issues.values()} | {issue.key: blockers}
|
||||
reached: set[str] = set()
|
||||
frontier = set(blockers)
|
||||
while frontier:
|
||||
reached |= frontier
|
||||
frontier = {blocker for key in frontier for blocker in waits_for.get(key, ()) if blocker in issues} - reached
|
||||
frontier = {blocker for key in frontier for blocker in waits_for[key] if blocker in issues} - reached
|
||||
return Failure(f"{label}: item {issue.number} would be blocked by itself through {', '.join(str(number(key)) for key in sorted(reached - {issue.key}, key=number))}; drop one of the blockers") if issue.key in reached else None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user