diff options
| author | capellancitizen <thecapellancitizen@gmail.com> | 2025-03-09 21:21:48 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-09 21:21:48 -0400 |
| commit | 99509df8d8abf1e7b701a4a09cf170a362f6d878 (patch) | |
| tree | a461549502fa9f37dc287789b6c7db81dfcd5368 /.github/mypy-github-formatter | |
| parent | 0d2fc24f25f87562f0755b53dad6204efad1330d (diff) | |
Mypy type correctness (#3199)
Diffstat (limited to '.github/mypy-github-formatter')
| -rwxr-xr-x | .github/mypy-github-formatter | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/.github/mypy-github-formatter b/.github/mypy-github-formatter new file mode 100755 index 00000000..dfc8309a --- /dev/null +++ b/.github/mypy-github-formatter @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +# A helper script that you can pipe the output of `mypy --output json` into Github actions workflow message commands +# so they show up in the code review panel and job output as warnings. +# (https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#about-workflow-commands) + +import json + +had_errors = False + +while True: + try: + line = input() + except EOFError: + break + if len(line) == 0: + break + + had_errors = True + + line = json.loads(line) + + # Format the line into a github command that will show up in the code review panel, + # as well as a note about the file and line so that it's clear to readers of the build log where + # errors were found + + # Could use line["severity"] to change the message type, but for now we just + # want to use these to flag potential commit issues rather than reject commits outright. + github_out = '::warning title=Type Checking,file={file},line={line},col={column}::{message} [{code}]'.format(**line) + hint = line["hint"] + if hint is not None: + github_out += f". HINT: {hint}" + + print(github_out) + print('(in {file}:{line})'.format(**line)) + +if not had_errors: + print("No type errors found!")
\ No newline at end of file |
