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

Mypy failed with code 2 #103

Closed jokance closed 1 year ago

jokance commented 2 years ago

Step 1: Are you in the right place?

Step 2: Describe your environment

Step 3: Describe the problem:

Steps to reproduce:

  1. Set environment variable MYPY_CONFIG_FILE_DIR to my project directory
  2. mypy.ini image
  3. click "check current file" button

The scan failed due to an exception: Mypy failed with code 2 com.leinardi.pycharm.mypy.exception.MypyToolException: Mypy failed with code 2   at com.leinardi.pycharm.mypy.mpapi.MypyRunner.runMypy(MypyRunner.java:324)   at com.leinardi.pycharm.mypy.mpapi.MypyRunner.scan(MypyRunner.java:266)   at com.leinardi.pycharm.mypy.checker.ScanFiles.scan(ScanFiles.java:109)   at com.leinardi.pycharm.mypy.checker.ScanFiles.checkFiles(ScanFiles.java:100)   at com.leinardi.pycharm.mypy.checker.ScanFiles.call(ScanFiles.java:74)   at com.leinardi.pycharm.mypy.checker.ScanFiles.call(ScanFiles.java:46)   at com.intellij.openapi.application.impl.ApplicationImpl$2.call(ApplicationImpl.java:326)   at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)   at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)   at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)   at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)   at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)   at java.base/java.security.AccessController.doPrivileged(Native Method)   at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)   at java.base/java.lang.Thread.run(Thread.java:829)

if I set mypy_path = $MYPY_CONFIG_FILE_DIR/src , it can run correctly, seem the Plugin not support multi paths

intgr commented 2 years ago

Hi

The plugin itself does not read the mypy configuration file. The plugin invokes the mypy command, and mypy exits with error code 2 in your situation.

Please try running mypy from command line directly and see what error message it produces.

jokance commented 2 years ago

Thanks for reply!

So I run mypy with command line: C:\PathToMyPy\mypy.exe --config-file F:\MyProject\mypy.ini F:\MyProject\src\main.py, it work correctly.

But if I run in mypy-pycharm plugin, it exits with error code 2, here is the settings: image

arrcher commented 2 years ago

Got the same issue with the same exception stack

The scan failed due to an exception: Mypy failed with code 2 com.leinardi.pycharm.mypy.exception.MypyToolException: Mypy failed with code 2   at com.leinardi.pycharm.mypy.mpapi.MypyRunner.runMypy(MypyRunner.java:324)   at com.leinardi.pycharm.mypy.mpapi.MypyRunner.scan(MypyRunner.java:266)   at com.leinardi.pycharm.mypy.checker.ScanFiles.scan(ScanFiles.java:109)   at com.leinardi.pycharm.mypy.checker.ScanFiles.checkFiles(ScanFiles.java:100)   at com.leinardi.pycharm.mypy.checker.ScanFiles.call(ScanFiles.java:74)   at com.leinardi.pycharm.mypy.checker.ScanFiles.call(ScanFiles.java:46)   at com.intellij.openapi.application.impl.ApplicationImpl$2.call(ApplicationImpl.java:326)   at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)   at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)   at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)   at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)   at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)   at java.base/java.security.AccessController.doPrivileged(Native Method)   at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)   at java.base/java.lang.Thread.run(Thread.java:829)

The system is MacOS Catalina if it matters.

jokance commented 2 years ago

Well, I check the source code, and found that we don't need these code below: image

I built another version and put here, enjoy! mypy-plugin-0.14.1.zip

bandophahita commented 1 year ago

@jokance do you have a branch that could be merged?