【发布时间】:2021-10-10 23:22:18
【问题描述】:
我将 mypy 守护程序与 vscode(和 this extension)一起使用,我希望它只检查我项目中的一些文件。
在我的pyproject.toml 中,我的 mypy 配置如下:
[tool.mypy]
scripts_are_modules = true
show_traceback = true
files = [
"server/**/*_some_files.py"
]
根据documentation,它应该可以工作,并且期望的行为是应该只检查server 目录下的.py 文件,但这不起作用。
用vscode运行显示,与配置不匹配的文件仍在检查中
[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>] = ...")
当我在命令行中运行 mypy 时,files 配置似乎仍然被忽略:
$ 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 可以解决问题,但我仍然想让files 工作)
【问题讨论】:
标签: python visual-studio-code mypy