Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

E131 applies inconsistently with nested calls

未关闭
#953 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@andribas404 已经在做这个了。

开始于 2020年12月9日。

  • #972 来自 @andribas404 —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
tooling

调研方向

首先使用 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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

PyCQA/pycodestyle 的其他 Issue

查看 PyCQA/pycodestyle 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。