首页 > 解决方案 > Default pylintrc completely disables pylint

问题描述

All I want to do is use the generated-members= line to disable the false "no-members" errors for several packages.

So, in the VS Code terminal, in my project root directory, I run:

pylint --generate-rcfile > .pylintrc

All linting warnings immediately disappear, even before I've change anything in the rc file. The only way I've been able to bring them back is by deleting .pylintrc. What am I doing wrong?

标签: visual-studio-codepylintpylintrc

解决方案


我能够诊断问题并找到解决方法。问题是 rcfile 是以错误的编码生成的。运行pylint mymodule给出以下错误:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

如此处所述。

我没有找到让 pylint 以正确编码生成配置文件的方法,但作为一种解决方法,我只是在 Notepad++ 中打开了 .pylintrc 文件,在那里将编码更改为 UTF-8,然后保存文件。之后,即使在 VS Code 中进行后续编辑,.pylintrc 文件仍保持正确的编码,从而允许 linting 正常工作。


推荐阅读