Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tapyu opened this issue Sep 24, 2024 · 1 comment
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed

Comments

@tapyu
Copy link

tapyu commented Sep 24, 2024

I am using pre-commit, which runs mypy with --ignore-missing-imports by default 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

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.

@tapyu tapyu added the bug Issue identified by VS Code Team member as probable bug label Sep 24, 2024
@karthiknadig
Copy link
Member

@tapyu are you passing --ignore-missing-imports via mypy-type-checker.args ? This extension is a thin wrapper around mypy. All it does is run mypy, and processes the results. If mypy itself does not read certain settings then we avoid doing it.

@karthiknadig karthiknadig self-assigned this Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed
Projects
None yet
Development

No branches or pull requests

2 participants