Python Pylint:覆盖单个文件中的最大行长度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30667612/
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
Pylint: overriding max-line-length in individual file
提问by ?ukasz Rogalski
Is is possible to change max-line-length
settings for one file out of a project (while performing all other checks defined in rc file on it)?
是否可以更改max-line-length
项目中一个文件的设置(同时执行 rc 文件中定义的所有其他检查)?
Ideally, it should behave like inline pylint: disable=x
comments.
理想情况下,它应该表现得像内联pylint: disable=x
注释。
I've tried putting this line on module level:
我试过把这一行放在模块级别:
# pylint: max-line-length=240
PyLint failed to recognize it:
PyLint 无法识别它:
my_file.py:15: [E0011(unrecognized-inline-option), ] Unrecognized file option 'max-line-length
Edit: I know I can disable line-too-long
check entirely, but to be honest I'd like to avoid doing so, just in case anyone would try to extend this module and add lines even longer than they are now.
编辑:我知道我可以line-too-long
完全禁用检查,但说实话,我想避免这样做,以防万一有人会尝试扩展此模块并添加比现在更长的行。
回答by Tryph
According to the doc, I think you cannot modify the pylint config in line.
but you can disable the warning for only one or few line(s) with # pylint: disable=line-too-long
:
根据doc,我认为您不能直接修改 pylint 配置。但是您可以使用以下命令禁用仅一行或几行的警告# pylint: disable=line-too-long
:
# disable for only one line
ridiculously_long_variable_name = "this is not a ridiculously long and useless python line" # pylint: disable=line-too-long
# disable for few (or more) lines
# pylint: disable=line-too-long
ridiculously_long_variable_name = "this is not a ridiculously long and useless python line"
# pylint: enable=line-too-long
回答by Nandeesh
You can pass the additional as below:
C:\Python27\Scripts\pylint.exe --max-line-length=240 <PATH TO FILE>
您可以通过以下附加内容:
C:\Python27\Scripts\pylint.exe --max-line-length=240 <PATH TO FILE>
回答by Kamal Hasan
pylint --max-line-length=240
works for me.
为我工作。
回答by ?mrüm ?etin
You can create .pylintrc
file in your python script to overwrite pylint settings and put inside
您可以.pylintrc
在 python 脚本中创建文件以覆盖 pylint 设置并放入
max-line-length=240
edit 240 based on your choice.
根据您的选择编辑 240。