leinardi/mypy-pycharm

"Check project" 10× slower than running mypy CLI on all files instead

Open

#114 opened on Oct 10, 2023

 (6 comments) (1 reaction) (0 assignees)Java (30 forks)github user discovery
Type: Enhancementhelp wanted

Repository metrics

Stars
 (206 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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.16.1
  • PyCharm/IDEA version: IntelliJ IDEA 2023.2.2, Build #IU-232.9921.47
  • Mypy version: mypy 1.5.1 (compiled: yes)

Step 3: Describe the problem:

Steps to reproduce:

I have a large-ish Django project (~600 files). We're using the django-stubs mypy plugin. When I run mypy on the whole project from the command line, it takes about 13 seconds to complete:

(venv) cs ~/.../Projects/captain$ time mypy captain/**/*.py
[...]
Found 7 errors in 3 files (checked 617 source files)

real	0m13.995s
user	0m12.252s
sys	0m1.457s

But when I run the Check Project action from the Mypy tool window in IntelliJ IDEA, I measured 113 seconds to complete. This seems like a too big difference, so I think something fishy is going on (e.g. that a separate mypy process is launched per file instead of for all files in a single call).

Expected Results:

I would expect the Check Project action to take about as long as running mypy from the command line, e.g. what I get when I either run mypy or mypy **/*.py or similar.

Relevant Code:

$ cat setup.cfg
[mypy]
warn_redundant_casts = True
warn_unused_ignores = True
warn_unreachable = True
extra_checks = True
strict_equality = True
files = captain
plugins =
    mypy_django_plugin.main

[mypy.plugins.django-stubs]
django_settings_module = "captain.project.settings"
$ pip freeze | grep -E 'django|mypy'
django-stubs==4.2.4
django-stubs-ext==4.2.2
mypy==1.5.1
mypy-extensions==1.0.0
pytest-django==4.5.2

Contributor guide