Configuring dmypy to check only some files with vscode

Viewed 329

I'm using mypy deamon with vscode (and this extension), and I wish to make it check only some of the files in my project.

In my pyproject.toml, I have mypy configured with something like this:

[tool.mypy]
scripts_are_modules = true
show_traceback = true
files = [
    "server/**/*_some_files.py"
]

According to the documentation, it should work and the desired behavior is that only .py files under the server directory should be checked, but this doesn't work.

Running it with vscode shows that files that do not match the configurations are still checked

[69] Check workspace: /home/pig208/myproject
[69] Using config file: pyproject.toml
[69] Received python path from Python extension: /home/pig208/myproject/.venv/bin/python
[69] Running dmypy in folder /home/pig208/myproject
/home/pig208/myproject/.venv/bin/python -m mypy.dmypy --status-file /home/pig208/.vscode-server/data/User/workspaceStorage/640660fb9d95e4f81c730061907f1d4c/matangover.mypy/dmypy-d1f12cdee9d0591a310a9c4402749ab59684e6e7.json run --log-file /home/pig208/.vscode-server/data/User/workspaceStorage/640660fb9d95e4f81c730061907f1d4c/matangover.mypy/dmypy-d1f12cdee9d0591a310a9c4402749ab59684e6e7.log -- . --show-column-numbers --no-error-summary --no-pretty --no-color-output --config-file pyproject.toml --python-executable /home/pig208/myproject/.venv/bin/python
[69] Mypy output:
analytics/foo.py:12:1: error: Need type annotation for "test_foo" (hint: "test_foo: Dict[<type>, <type>] = ...")

The files configuration still seems to be ignored when I running mypy in command line:

$ mypy . --config pyproject.toml
analytics/foo.py:12: error: Need type annotation for "test_foo" (hint: "test_foo: Dict[<type>, <type>] = ...")
Found 1 error in 1 file (checked 15 source files)

(exclude could solve the problem but I still want to get files to work)

1 Answers

It's due to the fact that the scripts you are checking are dependent on analytics/foo.py. Therefore, it is checked to determine the types in server/**/*_some_files.py.

Related