Add GitHub annotations format for `--output`
Adds a new output format as GitHub Workflow commands, aka annotations.
Refs:
- https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions
Closes https://github.com/python/mypy/issues/17612
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅
I would love to see this merged, many people asked for it in https://github.com/python/mypy/issues/10816 and https://github.com/python/mypy/issues/14962 !
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅
I assume this no longer needs to be marked as a draft?
I assume this no longer needs to be marked as a draft?
I've got a TODO comment in the diff that I want to address before opening the PR for review.
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅
Diff from mypy_primer, showing the effect of this PR on open source code:
schemathesis (https://github.com/schemathesis/schemathesis)
- File "/tmp/mypy_primer/old_mypy/venv/bin/mypy", line 8, in <module>
+ File "/tmp/mypy_primer/new_mypy/venv/bin/mypy", line 8, in <module>
- File "/tmp/mypy_primer/old_mypy/venv/lib/python3.12/site-packages/mypy/__main__.py", line 15, in console_entry
+ File "/tmp/mypy_primer/new_mypy/venv/lib/python3.12/site-packages/mypy/__main__.py", line 15, in console_entry
- File "/tmp/mypy_primer/old_mypy/venv/lib/python3.12/site-packages/mypy/main.py", line 119, in main
+ File "/tmp/mypy_primer/new_mypy/venv/lib/python3.12/site-packages/mypy/main.py", line 119, in main
- File "/tmp/mypy_primer/old_mypy/venv/lib/python3.12/site-packages/mypy/main.py", line 203, in run_build
+ File "/tmp/mypy_primer/new_mypy/venv/lib/python3.12/site-packages/mypy/main.py", line 203, in run_build
- File "/tmp/mypy_primer/old_mypy/venv/lib/python3.12/site-packages/mypy/build.py", line 191, in build
+ File "/tmp/mypy_primer/new_mypy/venv/lib/python3.12/site-packages/mypy/build.py", line 191, in build
- File "/tmp/mypy_primer/old_mypy/venv/lib/python3.12/site-packages/mypy/build.py", line 267, in _build
+ File "/tmp/mypy_primer/new_mypy/venv/lib/python3.12/site-packages/mypy/build.py", line 267, in _build
- File "/tmp/mypy_primer/old_mypy/venv/lib/python3.12/site-packages/mypy/build.py", line 2947, in dispatch
+ File "/tmp/mypy_primer/new_mypy/venv/lib/python3.12/site-packages/mypy/build.py", line 2947, in dispatch
- File "/tmp/mypy_primer/old_mypy/venv/lib/python3.12/site-packages/mypy/build.py", line 976, in write_deps_cache
+ File "/tmp/mypy_primer/new_mypy/venv/lib/python3.12/site-packages/mypy/build.py", line 976, in write_deps_cache
This would be a great feature; is it likely to make its way into 1.16?
This would be a great feature; is it likely to make its way into 1.16?
Probably not. See https://github.com/python/mypy/pull/11396#issuecomment-2103437776.
Since the output format of json has been merged, and it seems like they don't want to add another tool, can someone write something to convert from json to github format ?
Since the output format of
jsonhas been merged, and it seems like they don't want to add another tool, can someone write something to convert from json to github format ?
A simple one-liner you can add to your Github Workflow:
mypy . --output=json | jq -r '"::error title=Mypy issue,file=\(.file),line=\(.line),col=\(.column)::\(.message)"'
Thanks ! I'm not skilled enough with jq, couldn't figure it out (Didn't try with AI).
Cheers @pdgendt
I agree with @JelleZijlstra that it would be preferable not to have to maintain multiple output formats. Perhaps as a compromise we could document the one-liner that @pdgendt created?