我使用 vscode,发现 Python linter 无法检测何时使用与其签名定义不同类型的参数调用 python 函数。
在这种情况下,该函数需要 atyping.Type[Exception]而不是Exception:
Pycharm检测到这种情况:
我认为mypy不会检测到这个,因为它使用该typing模块(mypy检测内置类型中的类型不匹配)。
注意:我遵循了这篇 SO帖子( )中的标志建议,--check-untyped-defs但它不起作用。
当尝试在 vscode 中启动调试会话时,它会引发关于未找到指定任务的错误。我已经尝试过类似这样的其他 SO 问题的解决方案,但没有成功。
启动.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
...
},
{
"name": "MSEventHubs_Audit",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/audit-events.py",
"console": "integratedTerminal",
"args": [
"config/config.ini",
],
"envFile": "${workspaceFolder}/.env",
"env": {"PYTHONPATH": "${workspaceRoot}"},
"justMyCode": false,
"preLaunchTask": {
"task": "audit_tunnel"
}
},
{
...
},
]
}
Run Code Online (Sandbox Code Playgroud)
任务.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the …Run Code Online (Sandbox Code Playgroud)