E131 applies inconsistently with nested calls
评估
调研方向
首先使用 pycodestyle 2.6.0 重现两个赋值示例,并比较变量名变化时的 E131 结果。跟踪 E131 检查对嵌套方法调用和悬挂缩进的处理;完成标准是,等效的有效格式不再因赋值目标的长度而改变行为,并为这些示例添加回归覆盖。
由索引模型根据 Issue 内容生成。
描述
I often use an indentation format like this for long method chains with something like SQLAlchemy, which seems to be acceptable according to my reading of PEP8 and doesn't raise any errors when pycodestyle is run:
rows = db.engine.execute(
table.select()
.where(table.c.column1 == 'something')
.where(table.c.column2.is_(None))
.order_by(table.c.column3)
.limit(5)
)
However, if the name of the variable being assigned to is a particular length, E131 - continuation line unaligned for hanging indent is raised:
aaaaaaaa = db.engine.execute(
table.select()
.where(table.c.column1 == 'something') # E131
.where(table.c.column2.is_(None)) # E131
.order_by(table.c.column3) # E131
.limit(5) # E131
)
It seems to be related to having the = operator aligned with the indented lines? Adding just a single character to the left side of the assignment will remove the E131.
aaaaaaaab = db.engine.execute(
table.select()
.where(table.c.column1 == 'something')
.where(table.c.column2.is_(None))
.order_by(table.c.column3)
.limit(5)
)
Is this an issue in pycodestyle, or do I just not understand what's going on here?
$ pycodestyle --version
2.6.0
- 主要语言
- Python
- 星标
- 5.2k
- 派生
- 756
- 平均合并
- 5 小时 56 分钟
- 30 天内合并 PR
- 3
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PyCQA/pycodestyle 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 82/100
PyCQA/pycodestyle#1294 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
PyCQA/pycodestyle#1302 · 3 条评论 ·
-
难度 3/5 1-2 天 新手友好度 42/100
PyCQA/pycodestyle#1242 · 2 条评论 ·
-
Spurious E231 for nested format substitutions可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 3/5 1-2 天 新手友好度 68/100
PyCQA/pycodestyle#1241 · 2 条评论 · 4 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 45/100
PyCQA/pycodestyle#1217 ·
查看 PyCQA/pycodestyle 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
spec-kitty/spec-kitty#6112 ·
维护者通常 1 天内回复
-
[Bug]: OpenRouter streaming chunks report the requested router name instead of the model OpenRouter served可能已有人在做 @Mrun25 今天认领。 未关闭bug llm translation
难度 2/5 1-3 小时 新手友好度 75/100
BerriAI/litellm#46095 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
uberdeveloper/fastbt#29 ·
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
andrew-blake/melcloudhome#368 ·
维护者通常 1 天内回复
-
lane:discover
难度 2/5 1-3 小时 新手友好度 72/100
SPARDiffData/differential-data-collection#33 ·
维护者通常 1 天内回复