Skip to content

Conversation

@duncanmmacleod
Copy link
Contributor

This PR adds support for parsing JSON output from mypy (as generated by mypy --output json). The may be a route to more robust parsing, especially relative to potential upstream text format changes.

The main change is just updating the keys for the regex pattern to match what the JSON output provides. Testing on a local project the only change is the fingerprint.

I hope this change is welcome, am happy to change anything to suit the project, or have this rejected.

@soul-catcher
Copy link
Owner

Thank you for the pull request! Wow, I didn't know that mypy now supports JSON—that's awesome.

I'll review the PR in the next few days when I have some free time.

@UnknownPlatypus
Copy link

I didn't know that mypy now supports JSON—that's awesome.

The documentation is thin on this https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-O

This PR is looking good I think, it's probably more reliable overall

@soul-catcher
Copy link
Owner

soul-catcher commented Feb 5, 2025

I apologize for being inactive for almost three months. I faced some personal challenges.

After researching solutions, it appears the most effective approach for this project’s goals would be to create a mypy plugin by subclassing ErrorFormatter and implementing a custom formatting option, as seen in this pull request:
python/mypy#11396

I will work on converting this project into a mypy plugin while ensuring backward compatibility for existing users. If this approach proves unfeasible, I will merge the current pull request and update the README accordingly.

@soul-catcher soul-catcher merged commit c3b6e2b into soul-catcher:main Feb 22, 2025
2 checks passed
@soul-catcher
Copy link
Owner

Unfortunately there is no way to do it via MyPy plugin.

v1.2.0 with json parsing has just been released. Thank you for your contribution!

@duncanmmacleod duncanmmacleod deleted the mypy-output-json branch May 2, 2025 13:31
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.

3 participants