windows windows下如何为pylint指定配置文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1372295/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 13:05:16  来源:igfitidea点击:

How to specify a configuration file for pylint under windows?

pythonwindowspylint

提问by luc

I am evaluating pylint as source code checker and I would like to customize the maximum number of characters on a single line.

我正在将 pylint 评估为源代码检查器,并且我想在一行中自定义最大字符数。

I would like to use a configuration file. I've generated a template thanks to the --generate-rcfile command and I've made my modification.

我想使用配置文件。由于 --generate-rcfile 命令,我已经生成了一个模板,并且我已经进行了修改。

I am trying to run pylint --rcfile=myfile.rc but I can see that my changes are not taken into account by pylint. I've tried different location for my file : \Python26\Scripts\ and pylint.d in my user folder without any success.

我正在尝试运行 pylint --rcfile=myfile.rc 但我可以看到 pylint 没有考虑我的更改。我在我的用户文件夹中为我的文件尝试了不同的位置:\Python26\Scripts\ 和 pylint.d,但没有成功。

Does anybody know what I am doing wrong?

有谁知道我做错了什么?

Is it possible to use the configration file with pylint-gui? I can't do it too?

是否可以将配置文件与 pylint-gui 一起使用?我也做不到?

采纳答案by Flolagale

On Windows 7, a .pylintrc file in your home directory (typically C:\Users\myusername) will be automatically recognized.

在 Windows 7 上,您的主目录(通常为 C:\Users\myusername)中的 .pylintrc 文件将被自动识别。

Since creating a file beginning with a dot is not allowed from Windows file explorer, you can create a template using:

由于 Windows 文件资源管理器不允许创建以点开头的文件,因此您可以使用以下方法创建模板:

pylint --generate-rcfile > .pylintrc

回答by Micha? Niklas

Try setting PYLINTRC env variable.

尝试设置 PYLINTRC 环境变量。

I use batch:

我使用批处理:

@echo off
set PYLINTHOME=c:\tools
set PYLINTRC=c:\etc\pylint.conf
rem c:\Python27\python.exe c:\Python27\Lib\site-packages\pylint\lint.py %1 %2 %3 %4 %5 %6 %7 %8 %9
c:\Python27\python.exe c:\Python27\Lib\site-packages\pylint\lint.py %*