Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mypy executable is reported missing despite successful test #98

Open
2 tasks done
fralik opened this issue Mar 11, 2022 · 3 comments
Open
2 tasks done

Mypy executable is reported missing despite successful test #98

fralik opened this issue Mar 11, 2022 · 3 comments

Comments

@fralik
Copy link

fralik commented Mar 11, 2022

Step 1: Are you in the right place?

  • I have verified there are no duplicate active or recent bugs, questions, or requests
  • I have verified that I am using the latest version of the plugin.

Step 2: Describe your environment

  • Plugin version: 0.14.0
  • PyCharm/IDEA version: 2021.3.1
  • Mypy version: 0.780

Step 3: Describe the problem:

Steps to reproduce:

  1. I am using mypy from a different venv than the one I run my code with.
  2. Configure mypy executable
  3. Verify it works by clicking Test button.
  4. Click Check current button

Observed Results:

  • Scan results say Mypy found no problems
  • Event log reports that the executable can not be found, i.e. mypy missing.

Expected Results:

  • successful mypy check.

Relevant Code:

11:07	Mypy Plugin: Success: executable found!

11:08	Mypy Plugin (Mypy missing)
	The project interpreter is missing Mypy, which is needed to properly check the imports.
	Install Mypy
@intgr
Copy link
Collaborator

intgr commented Mar 11, 2022

I am using mypy from a different venv than the one I run my code with.

Yep, sorry, this is a use case that is not supported by the plugin currently.

You coud probably make it work with some hacks -- like creating a wrapper script named mypy in your project virtualenv bin directory, which deactivates the project venv and invokes mypy in the other virtualenv. But I haven't tried this.

@fralik
Copy link
Author

fralik commented Mar 11, 2022

I dug into the code. Looks like the initial issue is in the way how availability is checked, see here. When files are being added for scanning that function is called with showNotifications == true resulting in returning false even if path to mypy is set via plugin configuration.

@fralik
Copy link
Author

fralik commented Mar 11, 2022

I am observing another issue, which I am unsure if it is related or not. I now managed to run mypy, I see in the code that it returns 14 issues, but they are not displayed in the UI. UI indicates A scan is in progress and then Mypy found no problems.

fralik added a commit to fralik/mypy-pycharm that referenced this issue Mar 14, 2022
* Function checkMypyAvailable is called from various places in the code. If user specifies a custom mypy executable, which is not part of project's venv, then this function will return false when called with showNotifications == true. This happens because the function checks for mypy presence in the project's venv and it doesn't respect the custom path. This change makes the function check for mypy in the project's venv only if no custom path is present.
* Additional note. It may be better to check for mypy presence in the current venv after isMypyPathValid call. Thus, a user would get two notifications: mypy is not available, click here to install it.

Fixes leinardi#98
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 a pull request may close this issue.

2 participants