Skip to content

Respect JSON output mode for syntax errors#21386

Merged
hauntsaninja merged 2 commits intopython:masterfrom
AA-Turner:json-syntax-errors
May 1, 2026
Merged

Respect JSON output mode for syntax errors#21386
hauntsaninja merged 2 commits intopython:masterfrom
AA-Turner:json-syntax-errors

Conversation

@AA-Turner
Copy link
Copy Markdown
Member

Fixes #21370.

A

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Comment thread test-data/unit/outputjson.test
Copy link
Copy Markdown
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@hauntsaninja hauntsaninja merged commit eb0caa1 into python:master May 1, 2026
24 checks passed
@AA-Turner AA-Turner deleted the json-syntax-errors branch May 1, 2026 09:23
@ilevkivskyi
Copy link
Copy Markdown
Member

I think this will not work with parallel checking. You need to update build_worker/worker.py as well.

@AA-Turner
Copy link
Copy Markdown
Member Author

@ilevkivskyi I think this was added in your earlier PR #21319. I might be missing something though, do you have a pointer where I should look?

A

@ilevkivskyi
Copy link
Copy Markdown
Member

My PR simply brought the parallel checking to parity with what existed at the time in sequential mode. In particular, Errors() still needs the new argument in build_worker/worker.py.

To test this you will need a blocker error that happens at a later stage, for example:

$ echo break >bug.py
$ python -m mypy bug.py --output=json --num-workers=4
bug.py:1: error: "break" outside loop
Found 1 error in 1 file (errors prevented further checking)

(Also to write a unit test for this you will need to update test/testoutput.py, since currently it actually ignores the # flags: directive)

@AA-Turner
Copy link
Copy Markdown
Member Author

Thanks @ilevkivskyi, opened #21434.

A

ilevkivskyi pushed a commit that referenced this pull request May 7, 2026
Follow-up from #21386, fixes #21370.

A

Co-authored-by: Adam Turner <turner@hudson-trading.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Syntax errors are not emitted in JSON format when using --output=json

4 participants