E226: pycodestyle incorrectly warns about missing whitespace around operators
还没有人认领这个 Issue。
评估
调研方向
使用 example.py 片段和 pycodestyle --select E226 重现该报告。首先定位 pycodestyle 的 E226 实现,并检查它如何处理列表切片中的运算符。完成的标准是:普通的不带空格的算术表达式(例如 2+2)仍然会发出警告,而报告中切片内的 + 不会发出警告。
由索引模型根据 Issue 内容生成。
描述
Given the following example.py,
my_list = [1, 2, 3]
a = 2+2
b = my_list[1:1+1]
pycodestyle incorrectly warns about the missing whitespace for the + operator inside the list slice:
» pycodestyle --select E226 ./example.py
./example.py:2:6: E226 missing whitespace around arithmetic operator # OK
./example.py:3:16: E226 missing whitespace around arithmetic operator # incorrect
The first warning (line 2) is correct (line 2 should read a = 2 + 2); the second warning (line 3) is incorrect according to PEP-8:
Yes:
ham[1:9], ham[1:9:3], ham[:9:3], ham[1::3], ham[1:9:] ham[lower:upper], ham[lower:upper:], ham[lower::step] ham[lower+offset : upper+offset] ham[: upper_fn(x) : step_fn(x)], ham[:: step_fn(x)] ham[lower + offset : upper + offset]No:
ham[lower + offset:upper + offset] ham[1: 9], ham[1 :9], ham[1:9 :3] ham[lower : : upper] ham[ : upper]
Edit: okay, I'm not so sure I've got it 100%. The style I think is PEP-8 doesn't really seem to get listed anywhere, but even if I add spaces around the : (which is listed), I still get lints.
- 主要语言
- Python
- 星标
- 5.2k
- 派生
- 765
- 平均合并
- 1 天 20 小时
- 30 天内合并 PR
- 1
环境准备
- 没有 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可能重新可做 @inchang-ing 于 35 天前认领,目前没有进行中的 PR。 未关闭
难度 3/5 1-2 天 新手友好度 68/100
PyCQA/pycodestyle#1241 · 3 条评论 · 4 个 reaction ·
-
`exclude` is applied to `.`可能重新可做 @OnlineBunker 于 13 天前认领,目前没有进行中的 PR。 未关闭
难度 3/5 1-2 天 新手友好度 45/100
PyCQA/pycodestyle#1217 · 3 条评论 ·
查看 PyCQA/pycodestyle 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 79/100
micronaut-projects/micronaut-core#14585 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
langgenius/graphon#443 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
[BUG]: Management endpoints /v1/memory/stats and /v1/memory/counts bypass API key authentication未关闭
难度 2/5 1-3 小时 新手友好度 84/100
docling-project/docling-serve#788 ·
维护者通常 1 天内回复
-
Mend: dependency security vulnerability untriaged
难度 1/5 1 小时以内 新手友好度 78/100
opensearch-project/cross-cluster-replication#1805 ·
维护者通常 1 天内回复