Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions eng/tools/azure-sdk-tools/azpysdk/verifytypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ci_tools.functions import get_pip_command
from ci_tools.logging import logger

PYRIGHT_VERSION = "1.1.287"
PYRIGHT_VERSION = "1.1.407"
REPO_ROOT = discover_repo_root()


Expand Down Expand Up @@ -199,7 +199,21 @@ def get_type_complete_score(
f"Running verifytypes failed: {e.stderr}. See https://aka.ms/python/typing-guide for information."
)
return -1.0
report = json.loads(e.output)
try:
report = json.loads(e.output)
except (json.JSONDecodeError, TypeError):
logger.error(
f"pyright --verifytypes exited with code 1 but did not produce valid JSON output.\n"
f"stdout: {e.output}\n"
f"stderr: {e.stderr}\n"
f"Re-running without --outputjson for diagnostic output..."
)
Comment thread
l0lawrence marked this conversation as resolved.
non_json_commands = [c for c in commands[1:] if c != "--outputjson"] + ["--verbose"]
diag = self.run_venv_command(executable, non_json_commands, cwd, check=False)
Comment thread
l0lawrence marked this conversation as resolved.
logger.error(f"Diagnostic pyright stdout:\n{diag.stdout}")
if diag.stderr:
logger.error(f"Diagnostic pyright stderr:\n{diag.stderr}")
return -1.0
Comment thread
l0lawrence marked this conversation as resolved.
if check_pytyped:
pytyped_present = report["typeCompleteness"].get("pyTypedPath", None)
if not pytyped_present:
Expand All @@ -208,5 +222,19 @@ def get_type_complete_score(
return report["typeCompleteness"]["completenessScore"]

# library scores 100%
report = json.loads(response.stdout)
try:
report = json.loads(response.stdout)
except (json.JSONDecodeError, TypeError):
logger.error(
f"pyright --verifytypes exited successfully but did not produce valid JSON output.\n"
f"stdout: {response.stdout}\n"
f"stderr: {response.stderr}\n"
f"Re-running without --outputjson for diagnostic output..."
)
non_json_commands = [c for c in commands[1:] if c != "--outputjson"] + ["--verbose"]
diag = self.run_venv_command(executable, non_json_commands, cwd, check=False)
logger.error(f"Diagnostic pyright stdout:\n{diag.stdout}")
if diag.stderr:
logger.error(f"Diagnostic pyright stderr:\n{diag.stderr}")
return -1.0
return report["typeCompleteness"]["completenessScore"]
2 changes: 1 addition & 1 deletion pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"reportTypeCommentUsage": true,
"reportMissingImports": false,
"pythonVersion": "3.9"
"pythonVersion": "3.10"
}
Comment thread
l0lawrence marked this conversation as resolved.
Loading