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

Enabling plugin for CLion: de-prioritise presence of Python project SDK when checking mypy availability #106

Open
2 tasks done
bzoracler opened this issue Dec 25, 2022 · 0 comments

Comments

@bzoracler
Copy link

bzoracler commented Dec 25, 2022

Related issues/PRs:

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: N/A - CLion 2022.3.1 build #CL-223.8214.51
  • Mypy version: 0.991

Step 3: Describe the problem:

CLion cannot use the plugin, because the following code block can't grab the Python SDK (maybe because CLion doesn't have a concept of a Python SDK?). Simply removing the following block

Sdk projectSdk = ProjectRootManager.getInstance(project).getProjectSdk();
if (projectSdk == null
|| projectSdk.getHomeDirectory() == null
|| !projectSdk.getHomeDirectory().exists()) {
if (showNotifications) {
Notifications.showNoPythonInterpreter(project);
}
return false;
} else if (showNotifications) {
PyPackageManager pyPackageManager = PyPackageManager.getInstance(projectSdk);
List<PyPackage> packages = pyPackageManager.getPackages();
if (packages != null) {
if (packages.stream().noneMatch(it -> MYPY_PACKAGE_NAME.equals(it.getName()))) {
Notifications.showInstallMypy(project);
return false;
}
}
}

enables compilation and functionality of the plugin for CLion (you have to explicitly give Path to Mypy executable in the settings).

Steps to reproduce:

  1. Download the plugin https://github.com/leinardi/mypy-pycharm/releases/download/0.14.0/mypy-plugin-0.14.0.zip

  2. Install the plugin from disk in CLion, pointing to the .zip file downloaded above

    image

  3. Explicitly invoke the UI's (Check Current File)

    image

Observed Results:

This pops up repeatedly:

image

You cannot Configure Python interpreter, because the following option in Settings does not exist in CLion:

image


I built the modified plugin using the following quick steps:

  • Use IntelliJ IDEA to check out https://github.com/leinardi/mypy-pycharm.git in a new project

  • Remove the following lines

    Sdk projectSdk = ProjectRootManager.getInstance(project).getProjectSdk();
    if (projectSdk == null
    || projectSdk.getHomeDirectory() == null
    || !projectSdk.getHomeDirectory().exists()) {
    if (showNotifications) {
    Notifications.showNoPythonInterpreter(project);
    }
    return false;
    } else if (showNotifications) {
    PyPackageManager pyPackageManager = PyPackageManager.getInstance(projectSdk);
    List<PyPackage> packages = pyPackageManager.getPackages();
    if (packages != null) {
    if (packages.stream().noneMatch(it -> MYPY_PACKAGE_NAME.equals(it.getName()))) {
    Notifications.showInstallMypy(project);
    return false;
    }
    }
    }

  • Made any necessary gradle and/or Java version modifications

  • Use IntelliJ IDEA to Run tests in mypy-pycharm/src/test. The plugin should be built in mypy-pycharm/build/libs/mypy-pycharm-0.14.0.jar

  • Fill in the Path to Mypy executable:

    image

You should now have the mypy plugin working:

image

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

No branches or pull requests

1 participant