Improve "not found" error messages in `<sequence>.<method>()` failures
未关闭
还没有人认领这个 Issue。
interpreter-core
type-feature
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
The docstring of list.remove() says value parameter as shown below:
print(help(list.remove))
# remove(self, value, /) unbound builtins.list method
# Remove first occurrence of value.
#
# Raises ValueError if the value is not present.
But the error message says x instead of value as shown below and I don't think list.remove(x): is necessary:
v = ['a', 'b', 'c']
v.remove('B')
# ValueError: list.remove(x): x not in list
So, the error message should just say as shown below:
ValueError: value not in list
In addition, the docstring of bytearray.remove() says valueparameter as shown below:
print(help(bytearray.remove))
# remove(self, value, /) unbound builtins.bytearray method
# Remove the first occurrence of a value in the bytearray.
#
# value
# The value to remove.
And, the error message reasonably says value as shown below but I don't think found is necessary:
v = bytearray(b'abc')
v.remove(ord('B'))
# ValueError: value not found in bytearray
So, the error message should just say as shown below:
ValueError: value not in bytearray
Linked PRs
- gh-137509
- gh-139696
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先定位 list.remove() 和 bytearray.remove() 的实现和测试,并以报告中的示例作为行为基准。开始之前检查相关的 PR gh-137509 和 gh-139696;当两条错误消息与要求的措辞一致且相关测试通过时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100