microsoft / vscode-mypy

Linting support for Python using the mypy linter.
https://marketplace.visualstudio.com/items?itemName=ms-python.mypy-type-checker
MIT License
99 stars 25 forks source link

mypy is not ignoring items specified in mypy-type-checker.ignorePatterns #214

Open tabbea opened 8 months ago

tabbea commented 8 months ago

After switching from my local mypy installation to the VSCode mypy extension, I am struggling with mypy failing to ignore the specified files/folders.

My settings.json contains the following:

"mypy-type-checker.args": [
    "--strict",
    "--implicit-reexport",
    "--namespace-packages",
    "--show-column-numbers",
    // "--cache-dir=.mypy_cache/.vscode",
],
"mypy-type-checker.preferDaemon": true,
"mypy-type-checker.reportingScope": "workspace",
"mypy-type-checker.ignorePatterns": [
    "**/graveyard/*.py",
    "**/graveyard/*.txt",
],

The Mypy Type Checker confirms this when outputting [info] Global settings:

"ignorePatterns": [
    "**/graveyard/*.py",
    "**/graveyard/*.txt",
],

However, it still outputs the following:

/mnt/c/Users/bread/Documents/abz_code/graveyard/simulator_old.py:244: error: Name "ctp.SimTemplate" is not defined  [name-defined]

I would appreciate any advice on what I am doing wrong and/or what mypy is doing wrong. Thank you in advance!

karthiknadig commented 8 months ago

Duplicate of https://github.com/microsoft/vscode-mypy/issues/213

tabbea commented 8 months ago

May I request a review of whether or not this is a duplicate of #213?

I used @Mutantpenguin's is_match function from that thread and tested my own patterns and file paths:

import pathlib

def is_match(patterns: list[str], file_path: str) -> bool:
    """Returns true if the file matches one of the glob patterns."""
    if not patterns:
        return False
    return any(pathlib.Path(file_path).match(pattern) for pattern in patterns)

patterns: tp.List[str] = [
    "**/graveyard/*.py",
    "*/graveyard/*.py",
]

file_path: str = "/mnt/c/Users/bread/Documents/abz_code/graveyard/simulator_old.py"

And this returned True.

However, mypy is still typechecking the specified file path. As such, my issue seems to be different.