import json

targets = [
    "bet_recommender.py", "score_calculator.py", "db.py", "upset_engine_v2.py",
    "v20_ensemble.py", "v27_predictor.py", "betting_brain.py",
    "single_match_orchestrator.py", "v26_shadow_engine.py"
]

d = json.load(open("pyright_main_errors.json", encoding="utf-16"))
for diag in d["generalDiagnostics"]:
    if diag["severity"] == "error":
        fname = diag["file"]
        if any(t in fname for t in targets):
            # Print safely encoding to ascii to avoid charmap errors
            safe_fname = fname.split('ai-engine')[1].encode('ascii', 'ignore').decode()
            safe_msg = diag["message"].encode('ascii', 'ignore').decode()
            print(f"{safe_fname} L{diag['range']['start']['line']+1}: {safe_msg}")
