Modernize annotation usage in libregrtest
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug description:
Lib/test/libregrtest/results.py imports TYPE_CHECKING only to guard a type-only import:
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from xml.etree.ElementTree import Element
Now that explicit lazy imports are available, this can be replaced with:
lazy from xml.etree.ElementTree import Element
The stringized list['Element'] annotation can then become list[Element]. This keeps xml.etree.ElementTree from being imported eagerly while making the annotation name available at runtime.
Lib/test/libregrtest/mypy.ini should also target Python 3.15, following the approach used for pyrepl in gh-149985 and gh-149992.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
- gh-156403
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Lib/test/libregrtest/results.py 和 Lib/test/libregrtest/mypy.ini 开始;检查现有的注解和类型检查配置,然后比较 gh-149985 和 gh-149992 中的 pyrepl 方案。完成的标准是使用 lazy annotation import 和 runtime annotation,且不进行 eager XML imports,并让 mypy 以 Python 3.15 为目标。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- testing-qa
- Issue 类型
- 重构
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 30/100