leinardi / mypy-pycharm

A plugin providing both real-time and on-demand scanning of Python files with Mypy from within PyCharm/IDEA.
Apache License 2.0
188 stars 30 forks source link

Allow exit codes other than 0 or 1 if Mypy reports issues #105

Closed pwmarcz closed 1 year ago

pwmarcz commented 1 year ago

First time contributor checklist

Contributor checklist


Description

As discussed in #103, this makes the plugin not consider exit code other than 0 or 1 to be an abnormal exit, as long as Mypy also reported some issues. Mypy currently returns 2 in case of a syntax error as well as some other errors (such as break outside loop). This change makes sure these issues are correctly reported in Pycharm, instead of treating them as abnormal exit.

Type of Changes

Type
:bug: Bug fix

Related Issue

Closes #103.

intgr commented 1 year ago

I'm the author of this error handling code and I agree it needs an overhaul.

My thinking has shifted now, I think we should ignore the exit code entirely and instead look at whether stdout or stderr contain any messages. If something is written to stderr, it's almost always a crash of mypy.

In the case of syntax error as you mention, messages are written to stdout.