如何编写pep8配置(pep8.rc)文件? [英] How to write a pep8 configuration (pep8.rc) file?
本文介绍了如何编写pep8配置(pep8.rc)文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找到了pep8的文档,但无法理解如何编写它们.除了设置max-line-length和ignore,我什至找不到其他带有选项的示例.
I found the documentation for pep8 but wasn't able to understand how to write these. I couldn't even find any examples with options other than setting max-line-length and ignore.
我正在尝试编写一个.pep8.rc
文件,除其他外,我需要执行以下操作:
I am trying to write a .pep8.rc
file in which, among other things, I need to do the following:
- 启用显示源
- 启用统计信息
- 启用计数
- 排除目录(例如,
./random
)
- enable show source
- enable statistics
- enable count
- exclude a directory (say, for example
./random
)
有人可以举一个例子或一个例子吗?
Can somebody answer with an example or link to one?
推荐答案
首选方法是在项目的顶层使用setup.cfg
(.cfg的语法与
The preferred way is to use a setup.cfg
in the top-level of the project (.cfg has the same syntax as a .ini file), which should contain a [pep8]
section. For example:
[pep8]
ignore = E226,E302,E41
max-line-length = 160
注意:错误代码在 pep8文档中定义.
- autopep8找到与pep8相同的
[pep8]
部分. - flake8在setup.cfg中需要一个
[flake8]
部分. - yapf在setup.cfg中查找
[yapf]
部分. >
- autopep8 find this same
[pep8]
section as pep8. - flake8 needs a
[flake8]
section in setup.cfg. - yapf looks for a
[yapf]
section in setup.cfg.
这篇关于如何编写pep8配置(pep8.rc)文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文