Paddle
Paddle copied to clipboard
为 Paddle 框架 API 添加类型提示(Type Hints)Tracking Issue
任务简介
为 Paddle 框架 API 添加类型提示(Type Hints)
Python 在 3.0 版本引入了类型提示功能,并在 PEP 484 中将其规范化。之后随着相关规范和工具的逐渐完善,类型提示逐渐成为 Python 代码中的标准实践,如今较新的主流库也基本都提供了类型提示。由于 Python 本身类型高度动态化,类型提示的存在可以帮助开发者更快地了解代码的类型信息,提高代码的可读性和可维护性,结合工具还可以提供静态类型检查,在开发阶段就能发现一些潜在的类型错误。Paddle 框架由于历史原因尚未提供类型提示,本任务希望引入尽可能多的对 Paddle 有利的类型提示。
更多信息参考 为 Paddle 框架 API 添加类型提示(Type Hints)
RFC
- [x] https://github.com/PaddlePaddle/community/pull/858
🏗️ 第一阶段 前置任务 (2024/04/22 ~)
- [x] 1-1. Paddle 中引入
_typing模块 - [x] 1-2. Paddle 中引入
Tensorstub 和Paddle/python/paddle/py.typed文件 - [x] 1-3. Paddle 的 docs 中引入文档
《Paddle 中的类型提示》 - [x] 1-4. Paddle 的 CI 中引入
mypy对于 API 中 docstring 的示例代码的类型检查 - [x] 1-5. Paddle 的 docs 中正确的显示函数签名与描述的数据类型
- [x] 1-6. Paddle 的 docs 中不渲染
# type: ignore
任务列表
| 任务编号 | 认领人 github id | 任务 PR |
|---|---|---|
| 1-1 | @Asthestarsfalll @SigureMo | https://github.com/PaddlePaddle/Paddle/pull/63604 https://github.com/PaddlePaddle/Paddle/pull/63690 |
| 1-2 | @megemini | https://github.com/PaddlePaddle/Paddle/pull/63953 https://github.com/PaddlePaddle/Paddle/pull/64575 |
| 1-3 | @megemini | https://github.com/PaddlePaddle/docs/pull/6678 |
| 1-4 | @megemini | https://github.com/PaddlePaddle/Paddle/pull/63901 |
| 1-5 | @megemini | https://github.com/PaddlePaddle/docs/pull/6676 |
| 1-6 | @megemini | https://github.com/PaddlePaddle/docs/pull/6680 |
🔜 第二阶段 代码标注
- [x] 2-1. PFCC 宣讲 Type Hints
- [ ] 2-2. Paddle 的 docs 中引入文档《Paddle 类型提示 Q&A》,引入辅助管理文档或工具
- [ ] 2-3. 代码标注,
P1~P5(** 批量任务 **) https://github.com/PaddlePaddle/Paddle/issues/65008
任务列表
| 任务编号 | 认领人 github id | 任务 PR |
|---|---|---|
| 2-1 | @megemini | |
| 2-2 | @megemini | https://github.com/PaddlePaddle/docs/pull/6678 |
🔜 第三阶段 补充测试 (推荐)
- [ ] 3-1. CI 全量检查示例代码;CI 默认进行 type checking all
- [ ] 3-2. 单元测试文件,或补充测试 (_typing 模块等)
任务列表
| 任务编号 | 认领人 github id | 任务 PR |
|---|---|---|
| 3-1 | ||
| 3-2 |
🔜 第四阶段 收尾
- [ ] 4-1. 私有 API ,如
_C_ops - [ ] 4-2. 查缺补漏
- [ ] 4-3. 将 tools 中的单测统一放到 test 中进行管理
- [x] 4-4. 任务总结,PPT,答辩
任务列表
| 任务编号 | 认领人 github id | 任务 PR |
|---|---|---|
| 4-1 | ||
| 4-2 | ||
| 4-3 | ||
| 4-4 | @megemini |
认领方式
请大家以 comment 的形式认领任务,如:
【认领】1-1
@SigureMo @zrr1999 @Asthestarsfalll @gsq7474741 @sunzhongkai588 @luotao1
请悉知~ :)
【认领】1-1