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

mypy_path in the .ini file doesn't work as I expected when running checks on one file or module #118

Open rpeck opened 9 months ago

rpeck commented 9 months ago

Step 1: Are you in the right place?

Step 2: Describe your environment

Step 3: Describe the problem:

I understand that mypy has kind of funny behavior when it's run from somewhere other than the root directory of the project. However, I naively expected this plugin to always run mypy from where the .ini file is. Nope.

If you run checks on just one file, it seems to run mypy with cwd of that file. If you're as unfortunate as me and try to use mypy_path to point to local stubs or etc., with relative paths like is the norm in the mypy examples, then suddenly the plugin will be a no-op.

Steps to reproduce:

  1. Run failing checks on a single file a dir or two down, w/o using mypy_path. See the checks work.
  2. Set mypy = <my-code-dir> in your init file.
  3. Run it again on the single file and see your errors disappear.

Observed Results:

Expected Results:

Workaround:

Prefix all the paths in your .ini file with mypy_path = "$MYPY_CONFIG_FILE_DIR", like this:

mypy_path = "$MYPY_CONFIG_FILE_DIR"/stubs,"$MYPY_CONFIG_FILE_DIR"/automl