Skip to content

Commit 379c031

Browse files
Fix the output of the pytype analysis wrapper script
1 parent 64e59fd commit 379c031

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

pytype_runner.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ def to_markdown(me, fp, returncode, results, branch_url):
142142
mylink = f"[{me}]({branch_url}/{me}.py)"
143143
pytype_link = "[pytype](https://google.github.io/pytype)"
144144
if len(results) or returncode:
145-
fp.write(f"\n#### {mylink} reports these {pytype_link} error messages:\n")
145+
fp.write(f"\n#### {mylink} reports these error messages:\n")
146+
if not clen(results):
147+
fp.write(f"\n*Note: pytype exited with code {returncode}, check the CI logs*\n")
146148
fp.write(pd.DataFrame(results).to_markdown())
147149
else:
148150
fp.write(f"\n#### Congratulations, {mylink} reports no {pytype_link} errors.\n")
@@ -163,13 +165,20 @@ def setup_and_run_pytype_action(scriptname: str):
163165
branch = os.environ.get("GITHUB_HEAD_REF", None) or os.environ.get("GITHUB_REF_NAME", None)
164166
filelink_baseurl = f"{server_url}/{repository}/blob/{branch}"
165167
retcode, results = run_pytype_and_parse_annotations(xfail_files, filelink_baseurl)
166-
# Write the panda dable to a markdown output file:
168+
# Write the panda table to a markdown output file:
167169
summary_file = os.environ.get("GITHUB_STEP_SUMMARY", None)
168170
if summary_file:
169171
with open(summary_file, "w", encoding="utf-8") as fp:
170172
to_markdown(scriptname, fp, retcode, results, filelink_baseurl)
173+
fp.write("Results:")
174+
fp.write(pd.DataFrame(results).to_markdown())
175+
fp.write("Done: " + retcode * "with errors " + (not retcode) * "without errors")
171176
else:
172177
to_markdown(scriptname, sys.stdout, retcode, results, filelink_baseurl)
178+
sys.stdout.write("Results:")
179+
sys.stdout.write(pd.DataFrame(results).to_markdown())
180+
sys.stdout.write("Done: " + retcode * "with errors " + (not retcode) * "without errors")
181+
return retcode
173182

174183

175184
if __name__ == "__main__":

0 commit comments

Comments
 (0)