Repository navigation
Add GitHub annotations format for --output - #17771
edgarrmondragon wants to merge 1 commit into
Conversation
21efb22 to
70c8feb
Compare
This comment has been minimized.
This comment has been minimized.
70c8feb to
b330d80
Compare
This comment has been minimized.
This comment has been minimized.
|
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. |
b330d80 to
e03e7f1
Compare
This comment has been minimized.
This comment has been minimized.
b335987 to
fcdfa8f
Compare
| ::notice file=main,line=12,col=12,title=Mypy (misc)::Revealed type is "Overload(def (), def (x: builtins.int))". | ||
| ::error file=main,line=14,col=0,title=Mypy (call-overload)::No overload variant of "foo" matches argument type "str".%0A%0APossible overload variants:%0A def foo() -> None%0A def foo(x: int) -> None | ||
| ::error file=main,line=17,col=0,title=Mypy (call-arg)::Too many arguments for "bar". |
There was a problem hiding this comment.
This looks amazing! We would like to use it in our github actions! Will this PR be merged soon?
| general_group.add_argument( | ||
| "-O", | ||
| "--output", | ||
| metavar="FORMAT", |
There was a problem hiding this comment.
This was preventing the choices from being displayed in the --help output
This comment has been minimized.
This comment has been minimized.
fcdfa8f to
f22bffa
Compare
This comment has been minimized.
This comment has been minimized.
f22bffa to
2a9c638
Compare
|
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? |
Probably not. See #11396 (comment). |
|
Since the output format of |
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 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? |
|
Bummed that this was closed, but I agree that documenting @pdgendt's one-liner would be highly valuable, with a much lower maintenance cost. Any maintainers around to say if a contribution to do so would be welcomed? Any input on where it would belong in the docs? |
|
FYI, there are some (rather low) limits on the number of annotations that GitHub will show. See e.g.
My understanding is that only up to 10 errors from a single mypy step can be show. That makes me wonder how useful it would be to document this, or if it might lead to user confusion due to some errors being hidden. |
Maybe https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-O or https://mypy.readthedocs.io/en/stable/faq.html |

Adds a new output format as GitHub Workflow commands, aka annotations.
Refs:
Closes #17612