36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
|
|
def default_known_issues_path(script_file: str) -> Path:
|
|
return Path(script_file).resolve().parent.parent / "known_issues" / "runtime_known_issues.json"
|
|
|
|
|
|
def load_known_issue_ids(script_file: str, category: str, configured_path: str | None) -> tuple[Path | None, set[str]]:
|
|
if configured_path:
|
|
path = Path(configured_path).resolve()
|
|
else:
|
|
candidate = default_known_issues_path(script_file)
|
|
path = candidate if candidate.is_file() else None
|
|
|
|
if path is None:
|
|
return None, set()
|
|
|
|
if not path.is_file():
|
|
raise FileNotFoundError(f"known issues file not found: {path}")
|
|
|
|
data = json.loads(path.read_text(encoding="utf-8"))
|
|
raw_values = data.get(category, [])
|
|
if not isinstance(raw_values, list):
|
|
raise ValueError(f"known issues category '{category}' must be a list")
|
|
return path, {str(value) for value in raw_values}
|
|
|
|
|
|
def classify_issue_ids(observed: set[str], known: set[str]) -> tuple[set[str], set[str], set[str]]:
|
|
known_observed = observed & known
|
|
unexpected = observed - known
|
|
stale = known - observed
|
|
return known_observed, unexpected, stale
|