如何在 VS Code 中定义 pylance linting 参数(类似于“python.linting.pylanceArgs")? [英] How to define pylance linting arguments in VS Code (something like "python.linting.pylanceArgs")?

查看:38
本文介绍了如何在 VS Code 中定义 pylance linting 参数(类似于“python.linting.pylanceArgs")?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直到大约 3 周前,我一直在使用 pylintVS Code 中整理我的 python 文件.

Until around 3 weeks ago, I'd been using pylint for linting my python-files in VS Code.

然后,我启用了 pylance 替换了 pylint.然而,pylance 并未列在 特定的 linter-VS Code 提供的列表.

Then, I enabled pylance replacing pylint. Yet, pylance is not listed in the specific linter-list provided by VS Code.

现在,pylance 不会向我显示未使用的模块导入.我怀疑这不包含在 pylance 的默认 linting 参数中,所以我试图找出如何修改它们类似于使用 pylint 这样做的过程,例如记录此处 并像so(插入到settings.json - 当前工作区的文件中):

Now, pylance doesn't show me unused module imports. I suspect this is not included in the default linting arguments of pylance, so I tried to find out how to modify them akin to the procedure of doing so with pylint, such as documented here and implemented like so (inserted into the settings.json - file of the current workspace):

"python.linting.pylintArgs": [
    "--max-line-length=80",
    "--disable=W0142,W0403,W0613,W0232,R0903,R0913,C0103,R0914,C0304,F0401,W0402,E1101,W0614,C0111,C0301"
]

如何以类似的方式自定义 pylance 的 linting 规则?

How can I customize in a similar fashion the linting rules of pylance?

推荐答案

python.linting.pylintArgs 设置仅适用于 pylint 不使用pylance(据我所知)

The python.linting.pylintArgs setting is for pylint only and is not used by pylance (as far as I know)

您正在寻找的设置似乎就是这个 python.analysis.diagnosticSeverityOverrides:

It seems the setting you are looking for is this one python.analysis.diagnosticSeverityOverrides:

{
    "python.analysis.diagnosticSeverityOverrides": {
        "reportUnusedImport": "information"
    }
} 

有关 pylance 设置的列表,您可以访问 此页面这个.

For the list of pylance settings you can visit this page and this one.

这篇关于如何在 VS Code 中定义 pylance linting 参数(类似于“python.linting.pylanceArgs")?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆