How to tell Spyder's style analysis PEP8 to read from a setup.cfg or increase max. line length?

Deadly 提交于 2019-12-18 18:54:15

问题


I am using Spyder 2.3.1 and python(x, y).

In the preferences of Spyder you can activate "Style analysis". This is quite nice, but I want to increase the max. tolerable line length. The standard setting for PEP8 is 79 characters. This can be changed through a setup.cfg with the content:

[pep8]
max-line-length = 99

This can be read here: http://pep8.readthedocs.org/en/latest/intro.html#related-tools

Where do I put a setup.cfg so Spyder/PEP8 will recognize my new limit? Or is there an other way to set this limit or to ignore E501 (line to long)? Just setting "Show vertical line after 99 characters" in Spyder does not help.


回答1:


According to the link cited by @Werner:

http://pep8.readthedocs.org/en/latest/intro.html#configuration

what you need to do is to create a file called ~/.config/pep8 (On Linux/Mac) or ~/.pep8 (on Windows), and add these lines to it:

[pep8]
max-line-length = 99

I tested it in Spyder and it works as expected.




回答2:


Inspired by Minh's comment I've been able to make this work for spyder 3.8 by doing the following. Find out the ~ directory using

import os; os.path.expanduser('~')

(see remark ofJustin Harris)

Then add a file to the ~ directory called .pycodestyle containing:

[pycodestyle]
max-line-length = 99

(see Carlos Cordoba's answer)

Restart spyder [EDIT: according to the comments below this is not needed]. This is actually just combining most of the above remarks and answers.




回答3:


References to "pep8" are obsolete. The package has been renamed to "pycodestyle".




回答4:


The tox.ini with a pep8 section or a setup.cfg at the project level should do.

http://pep8.readthedocs.org/en/latest/intro.html#configuration




回答5:


using the Spyder 4.0.0.dev0 went to my ~/.config/spyder.ini, ensured that my spyder application was not running change the dictionary value 'maxLineLength': 100 from 'maxLineLength': 79.

Started my app and it worked now if you edit the file while your spyder app is running upon shutting down it will overwrite what ever is in the ~/.config/spyder.ini.

Ensure it is not running and make the necessary changes



来源:https://stackoverflow.com/questions/26426689/how-to-tell-spyders-style-analysis-pep8-to-read-from-a-setup-cfg-or-increase-ma

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!