microsoft / microsoft/vscode-mypy

`vscode-mypy` wrongly linters missing imports when `mypy` is used with `pre-commit`

Open
#324 1 comment 0 reactions 1 assignee View on GitHub

@karthiknadig is already working on this.

Since Sep 25, 2024.

bug triage-needed
Dominant language
Python
Stars
150
Forks
39
Avg merge
21h 45m
Merged PRs (30d)
8

Description

I am using pre-commit, [which runs `mypy` with `--ignore-missing-imports` by default](https://github.com/pre-commit/mirrors-mypy?tab=readme-ov-file#using-mypy-with-pre-commit) with the following configuration:
```
- repo: https://github.com/pre-commit/mirrors-mypy
rev: '' # Use the sha / tag you want to point at
hooks:
- id: mypy
```

However, this extension wrongly linters my code as if the import are not being ignored.

![image](https://github.com/user-attachments/assets/192974a6-0532-44da-8cc2-c4aedb48278b)

Nevertheless, the pre-commit is passing in all hooks, including `mypy`

```
(scintpy-py3.12) PS C:\Users\rubem\scintpy> git commit -m 'test mypy arguments'
[WARNING] The 'rev' field of repo 'https://github.com/pre-commit/mirrors-mypy' appears to be a mutable reference (moving tag / branch). Mutable references are never updated after first install and are not supported. See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details. Hint: `pre-commit autoupdate` often fixes this.
ruff.....................................................................Passed
ruff-format..............................................................Passed
mypy.....................................................................Passed
pyupgrade................................................................Passed
[main 8ed6934] test mypy arguments
1 file changed, 1 insertion(+), 1 deletion(-)
```

I suggest that this extension should be `.pre-commit-config.yaml`-aware and run `dmypy` with `--ignore-missing-imports` so that the lintering matches the actual hook.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.