为什么 PyCharm 使用 120 个字符行,即使 PEP8 指定了 79 个? [英] Why does PyCharm use 120 Character Lines even though PEP8 Specifies 79?

查看:103
本文介绍了为什么 PyCharm 使用 120 个字符行,即使 PEP8 指定了 79 个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PEP8 明确指定了 79 个字符,但是,PyCharm 默认为 120 个并给我警告PEP8:行太长(...> 120 个字符)".

PEP8 clearly specifies 79 characters, however, PyCharm defaults to 120 and gives me the warning "PEP8: line too long (... > 120 characters)".

之前版本的 PEP8 使用 120 并且 PyCharm 没有更新其 PEP8 检查器吗?我找不到 PEP8 指南的任何先前版本,但是,我可以轻松找到 PEP8 Python 脚本的先前版本.

Did previous versions of PEP8 use 120 and PyCharm not update its PEP8 checker? I couldn't find any previous versions of the PEP8 Guide, however, I can easily find previous version of the PEP8 Python scripts.

我正在开始一个新的 Python 项目,但不确定要使用哪个.

I'm starting a new Python project and I'm not sure which to use.

参考文献:

http://legacy.python.org/dev/peps/pep-0008/

推荐答案

PyCharm 建立在 IntelliJ 之上.IntelliJ 的默认行长为 120 个字符.

PyCharm is built on top of IntelliJ. IntelliJ has a default line length of 120 characters.

这可能是因为您无法在仅 80 个字符的行中放入一个常见的 Java 名称,例如:@annotated public static MyObjectFactoryFactory enterpriseObjectFactoryFactoryBuilderPattern {.(我是在开玩笑,但按照惯例,Java 名称确实倾向于更长).

This is probably because you can't fit a common Java name like: @annotated public static MyObjectFactoryFactory enterpriseObjectFactoryFactoryBuilderPattern { in a mere 80 character line. (I'm poking fun, but Java names do tend to be longer by convention).

pep8 检查器是可配置的,因此您可以指定更好的最大行长度 - 例如 79 个字符.

The pep8 checker is configurable, so you can specify a better max line length - like 79 characters.

该错误具有误导性,因为 pep8 检查器使用类似 "PEP8: line too long(... > %s characters)" % max_line_setting 的内容格式化文本.所以它使用了 pep8 检查器,具有特定的配置,而不是声称 pep8 指定了 120 个字符的行.

The error is misleading because the pep8 checker formats the text with something like "PEP8: line too long(... > %s characters)" % max_line_setting. So it's using the pep8 checker, with a specific configuration, not claiming that pep8 specifies a 120 character line.

这篇关于为什么 PyCharm 使用 120 个字符行,即使 PEP8 指定了 79 个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆