在pycharm中配置pep8.py命令行选项

2024-04-19 12:26:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我可以配置PyCharm在执行pep8样式自动检查时发送给pep8.py的命令行参数吗?我想做一些像

$ pep8 --ignore=E231 foo.py

但是,在“项目设置”->;“检查”下的“PyCharm”中,我只看到用于聚合启用/禁用PEP8样式检查的选项,而没有用于启用/禁用特定PEP8冲突的选项。


Tags: 项目命令行pygt参数foo选项样式
3条回答

您可以使用pep8 rc文件执行以下操作:

# in ~/.config/pep8
[pep8]
ignore = E231

如果需要为每个项目设置不同的选项,也可以:

Configuration: The project options are read from the [pep8] section of the tox.ini file or the setup.cfg file located in any parent folder of the path(s) being processed. Allowed options are: exclude, filename, select, ignore, max-line-length, count, format, quiet, show-pep8, show-source, statistics, verbose.

如果要强制pep8忽略长线检测 类型:

1)每个python代码长行末尾的noqa。 2) --#noqa位于每个sql代码长行的末尾。

示例:

c.execute(“”从日志内部连接项目中选择标题、计数(路径)--noqa

在这里找到了解决方案:http://iambigblind.blogspot.de/2013/02/configuring-pep8py-support-in-pycharm-27.html

只需将E501添加到忽略错误列表中,警告就会在PyCharm 3(和4)中消失。

编辑:

根据JetBrains网站的评论,有人说“截至Pycharm 2017.3.4的错误代码是E111”,参见https://intellij-support.jetbrains.com/hc/en-us/community/posts/205816889-Disable-individual-PEP8-style-checking-line-length-?page=1#community_comment_360000113310

相关问题 更多 >