PEP8 E127 的工作方式与我收到的警告之间存在冲突
下面是我的代码的屏幕截图,显示它不遵守 PEP 8 规则中的 E127: 然而,在这个链接中,被解释为良好实践的是我所拥有的。此外,当我使用快捷键 Ctrl + Alt + I
(和 Alt + Shift + Enter
)时,它们是 PyCharm 快捷键,用于根据以下格式格式化行(和文件) PEP 8,这(上面)是我获得的格式(如果我偏离它,按下这些按钮会让我回到这个(上面)格式)。
我错过了什么吗?
编辑:另一种情况是不在括号内但带有 =
符号,其中 niko 的解决方案不适用: https://i.sstatic.net/KIAma.png。
Here below is a screenshot of my code saying it doesn't respect E127 from the PEP 8 rules:
However, in this link, what is explained as good practice is what I have. Furtheremore, when I use the shortcuts Ctrl + Alt + I
(and Alt + Shift + Enter
) which are the PyCharm shortcuts to format the line (and the file) according to PEP 8, this (above) is the formatting I obtain (and if I deviate from it, pressing those bring me back to this (above) formatting).
Am I missing something?
EDIT: Another situation when it's not inside parentheses but with an =
sign where niko's solution does not apply: https://i.sstatic.net/KIAma.png.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道你的具体问题,但就我个人而言,我缩进的方式如下
PyCharm 从未抱怨过这种风格(我不认为它反对任何 PEP,但我可能是错的)。
当函数(调用)内部有很多和/或很长的参数时,感觉更容易阅读。
有点中间的方法会像这样
Edit
Long strings
Idk about your specific question, but personally, the way I indent is as follows
PyCharm never complained about that style (I don't think it is against any PEP but I might be wrong).
It feels easier to read when there are many and/or long parameters inside of functions (calls).
A somewhat in the middle approach would be something like this
Edit
Long strings