mypy-pycharm icon indicating copy to clipboard operation
mypy-pycharm copied to clipboard

Check-* ignores exclude directive in mypy.ini

Open WolfByttner opened this issue 2 years ago • 4 comments

Step 1: Are you in the right place?

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

Step 2: Describe your environment

  • Plugin version: 0.16.2
  • PyCharm/IDEA version: Pycharm Professional 2023.3 (Mac)
  • Mypy version: 1.8.0

Step 3: Describe the problem:

The mypy plugin does not appear to respect (or pick up) the exclude directive in a mypy config file. This applies when running all scans (Project/Module/Modified Files/Current Change List). It applies whether I try to ignore one file or multiple files, and whether they are at the root directory or not. Below, I have illustrated the problem with bazelisk.py.

This is the basic structure of the mypy.ini file (note the leading and trailing newlines):


[mypy]
exclude = (?x)(bazelisk\.py)

I have tried different variations of the exclude directive, including the below:

  • exclude = bazelisk\.py
  • exclude = bazelisk.py
  • exclude = ^bazelisk.py
  • exclude = ^bazelisk.py$
  • exclude = ^bazelisk\.py$
  • exclude = bazelisk\.py$
  • exclude = "bazelisk\.py"
  • exclude = (?x)(bazelisk\.py)

Mypy provides the following example file format:

[mypy]
exclude = (?x)(
    ^one\.py$    # files named "one.py"
    | two\.pyi$  # or files ending with "two.pyi"
    | ^three\.   # or files starting with "three."
  )

They also note that "The above is equivalent to: (^one\.py$|two\.pyi$|^three\.)."

These are my mypy settings:

image

I have tried setting the config file both in the Path to config file window and in the Arguments window.

Steps to reproduce:

  1. Add a file called bazelisk.py with mypy errors (I used this file). Note that I added this file in the root folder, but the issue appears to occur no matter the location of the file.
  2. Run any of the mypy checks (Project/Module/Modified Files/Current Change List) in the mypy tab.

Observed Results:

Mypy found errors in bazelisk.py

image

Expected Results:

Mypy should not find errors in bazelisk.py

WolfByttner avatar Dec 31 '23 13:12 WolfByttner

having the same issue

sombek avatar Sep 05 '24 07:09 sombek

For me setting the config-file in the setting also does not work. I was able to get it to work by specifying the absolute path to the file in the Arguments: Arguments: --no-pretty --config-file <absolute-path>

wullli avatar Oct 16 '24 14:10 wullli

For me setting the config-file in the setting also does not work. I was able to get it to work by specifying the absolute path to the file in the Arguments: Arguments: --no-pretty --config-file <absolute-path>

This still does not fix the issue for me 😦

Techcable avatar Feb 20 '25 09:02 Techcable

Hi everyone,

A new developer, @szabope, has created a full rewrite of this Mypy plugin. The new plugin is actively maintained and addresses many of the issues found here.

You can find the new plugin on the JetBrains Plugin Marketplace: Mypy Plugin The source code is available here: GitHub Repository

Please give it a try, as the old plugin will soon be archived.

leinardi avatar Feb 20 '25 09:02 leinardi