在 Eclipse 中为 PEP8 设置最大行长的问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15460648/
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-19 20:12:17  来源:igfitidea点击:

Issue setting max line length for PEP8 in Eclipse

pythoneclipsepydevpep8

提问by Caumons

I am using Eclipse Junoon an Ubuntu x64machine.

Eclipse JunoUbuntu x64机器上使用。

I would like to change the default max line length for the PyDev's PEP8, but I can't!

我想更改PyDev's PEP8的默认最大行长,但我不能!

I go to Window/Preferences/PyDev/Editor/Code Analysis/pep8.py and set the following arguments:

我转到 Window/Preferences/PyDev/Editor/Code Analysis/pep8.py 并设置以下参数:

--max-line-length=100

What I am doing wrong? After setting this, I have done a code analysis but then the line length seems to be ignored and I don't want this.

我做错了什么?设置好之后,我做了一个代码分析,但是行长似乎被忽略了,我不想要这个。

回答by Sebastian Wiesinger

The current Pydev has a pep8.py that can set the --max-line-lengthparameter. You can just go to

当前Pydev有一个pep8.py可以设置--max-line-length参数。你可以去

Window → Preferences → Pydev → Editor → Code Analysis → pep8.py

and set Arguments to:

并将参数设置为:

--max-line-length=99

回答by Caumons

To set the maximum line length, go to:

要设置最大行长度,请转到:

Window/Preferences/PyDev/Editor/Code Analysis/pep8.py

Then, open the file at Location of pep8.py, search for MAX_LINE_LENGTHvariable and set it to the length you want. You just have to restart Eclipse and that's it! :D

然后,在 处打开文件Location of pep8.py,搜索MAX_LINE_LENGTH变量并将其设置为您想要的长度。您只需要重新启动 Eclipse,就可以了!:D

Note: make sure PyDev's options Do code analysis?is checked.

注意:确保Do code analysis?选中PyDev 的选项。

回答by Henke

The problem is that the maximum line length is not implemented in the pep8.py used by pydev. This means that it will not recognize the maximum line length.

问题是pydev使用的pep8.py中没有实现最大行长。这意味着它不会识别最大行长度。

If you use '- max-line-length "as you can see in the logs that it is subject to one exception and that is when it is about to parse arguments. If you open the file that the error comes from, one can see that "- max-line-length" is missing.

如果您使用“- max-line-length”,正如您在日志中看到的那样,它会受到一个异常的影响,并且即将解析参数。如果您打开错误来自的文件,则可以看到缺少“- max-line-length”。

The log can be obtained through Help-> Aptana-> View Log File. Check for error in "pep8.py"

日志可以通过Help->Aptana->View Log File获取。检查“pep8.py”中的错误

To make this work you probably have to ask that they fix this upstream or fix it yourself locally.

要完成这项工作,您可能必须要求他们在上游修复此问题或在本地自行修复。

回答by Don Kirkby

It sounds like PyDev's support for PEP8 has improved since this question was asked. I got it to work by going to Window: Preferences: PyDev: Editor: Code Analysis, and then clicking on the pep8.py tab.

自从提出这个问题以来,PyDev 对 PEP8 的支持听起来似乎有所改善。我通过转到窗口:首选项:PyDev:编辑器:代码分析,然后单击 pep8.py 选项卡使其工作。

I entered the argument --max-line-length=100, but it was ignored as you describe. However, when I enabled the "Use system interpreter" checkbox, the arguments were used. I also found that the --ignoresetting works.

我输入了参数--max-line-length=100,但正如您所描述的那样被忽略了。但是,当我启用“使用系统解释器”复选框时,使用了参数。我还发现该--ignore设置有效。

I am using PyDev 4.2.0 with Eclipse 4.4.2 (Luna).

我将 PyDev 4.2.0 与 Eclipse 4.4.2 (Luna) 一起使用。