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
194 stars 31 forks source link

Support for mypy using WSL interpreter #110

Open wholmen opened 1 year ago

wholmen commented 1 year ago

I have my repository and python interpreter set up in WSL 2. I would like to use Mypy in Pycharm, but I can't get it to work.

I have tried to use the mypy installation in the virtual environment installed in WSL and I have tried to install Mypy in Windows and use that on my WSL projects.

Neither work.

Would it be possible for the interpreter to find the mypy package in the project interpreter when that interpreter is set up on WSL?

Edit: It seems like the developer of Ruff plugin has found a good solution for this. Maybe there are possibilities of implementing the same logic? https://github.com/koxudaxi/ruff-pycharm-plugin/issues/72

aploium commented 1 year ago

If it's not feasible to support calling mypy under PyCharm's native WSL, then a fallback "mixed" solution could also be acceptable. That is: installing an extra copy of python (and mypy) under the Windows environment, while the project interpreter is WSL, and then manually forcing the plugin to call mypy under Windows. At present, in order to use mypy plugin, I am forced to set the project interpreter to Windows.

wholmen commented 1 year ago

I think it's feasible to call mypy under PyChams native WSL. I got the impression that it wasn't a big problem to adjust the Ruff plugin

aploium commented 1 year ago

I think it's feasible to call mypy under PyChams native WSL. I got the impression that it wasn't a big problem to adjust the Ruff plugin

Actually, as a user, I just want to express: oh please, I'm hungry to have mypy there lol. There is an open pull request #99 which may be a temporary solution, but I don't know how to build it to working plugin

leinardi commented 1 year ago

@aploium to build the plugin you just have to checkout the PR code and run ./gradlew clean buildPlugin. It will generate a mypy-plugin-<version>.zip plugin somewhere inside the build directory (probably in build/distribution iirc).

aploium commented 1 year ago

@aploium to build the plugin you just have to checkout the PR code and run ./gradlew clean buildPlugin. It will generate a mypy-plugin-<version>.zip plugin somewhere inside the build directory (probably in build/distribution iirc).

I've succeed to build the patched version, and manually set the correct mypy.exe path in native windows. Sadly, it still shows error No Python interpreter configured for the project.. :(

aploium commented 1 year ago

finally, I modified the MypyRunner.java, commented out the checkMypyAvailable(), force it return ture, and hardcoded my mypy.exe path in getMypyPath(), then rebuild the plugin. which makes my mypy work by always reach the windows native mypy.exe, regardless what the project interpreter is.

gogognome commented 1 month ago

What's the status of this issue? The last update seems to be more than a year ago...