1818from ci_tools .functions import get_pip_command
1919from ci_tools .logging import logger
2020
21- PYRIGHT_VERSION = "1.1.287 "
21+ PYRIGHT_VERSION = "1.1.407 "
2222REPO_ROOT = discover_repo_root ()
2323
2424
@@ -199,7 +199,21 @@ def get_type_complete_score(
199199 f"Running verifytypes failed: { e .stderr } . See https://aka.ms/python/typing-guide for information."
200200 )
201201 return - 1.0
202- report = json .loads (e .output )
202+ try :
203+ report = json .loads (e .output )
204+ except (json .JSONDecodeError , TypeError ):
205+ logger .error (
206+ f"pyright --verifytypes exited with code 1 but did not produce valid JSON output.\n "
207+ f"stdout: { e .output } \n "
208+ f"stderr: { e .stderr } \n "
209+ f"Re-running without --outputjson for diagnostic output..."
210+ )
211+ non_json_commands = [c for c in commands [1 :] if c != "--outputjson" ] + ["--verbose" ]
212+ diag = self .run_venv_command (executable , non_json_commands , cwd , check = False )
213+ logger .error (f"Diagnostic pyright stdout:\n { diag .stdout } " )
214+ if diag .stderr :
215+ logger .error (f"Diagnostic pyright stderr:\n { diag .stderr } " )
216+ return - 1.0
203217 if check_pytyped :
204218 pytyped_present = report ["typeCompleteness" ].get ("pyTypedPath" , None )
205219 if not pytyped_present :
@@ -208,5 +222,19 @@ def get_type_complete_score(
208222 return report ["typeCompleteness" ]["completenessScore" ]
209223
210224 # library scores 100%
211- report = json .loads (response .stdout )
225+ try :
226+ report = json .loads (response .stdout )
227+ except (json .JSONDecodeError , TypeError ):
228+ logger .error (
229+ f"pyright --verifytypes exited successfully but did not produce valid JSON output.\n "
230+ f"stdout: { response .stdout } \n "
231+ f"stderr: { response .stderr } \n "
232+ f"Re-running without --outputjson for diagnostic output..."
233+ )
234+ non_json_commands = [c for c in commands [1 :] if c != "--outputjson" ] + ["--verbose" ]
235+ diag = self .run_venv_command (executable , non_json_commands , cwd , check = False )
236+ logger .error (f"Diagnostic pyright stdout:\n { diag .stdout } " )
237+ if diag .stderr :
238+ logger .error (f"Diagnostic pyright stderr:\n { diag .stderr } " )
239+ return - 1.0
212240 return report ["typeCompleteness" ]["completenessScore" ]
0 commit comments