Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Typing] 为 Paddle 框架 API 添加类型提示(Type Hints)的项目总结。 #68

Merged
merged 10 commits into from
Sep 2, 2024

Conversation

megemini
Copy link
Contributor

@megemini megemini commented Sep 1, 2024

为 Paddle 框架 API 添加类型提示(Type Hints)的项目总结。

关联:PaddlePaddle/Paddle#63597

@sunzhongkai588 @SigureMo @luotao1

请评审 ~

Copy link

netlify bot commented Sep 1, 2024

Deploy Preview for pfccblog ready!

Name Link
🔨 Latest commit 1c47250
🔍 Latest deploy log https://app.netlify.com/sites/pfccblog/deploys/66d59ad06113d200085be22d
😎 Deploy Preview https://deploy-preview-68--pfccblog.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@jzhang533 jzhang533 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻 👍🏻 👍🏻
太赞了。

- 粒度控制
- 单元测试

所谓「粒度控制」是指,很难用统一的标注来划分哪些类型需要归类入 `_typing`,哪些则直接使用 Python 的基础类型进行组合。比如,`_typing` 中的 `IntSequence = Sequence[int]`,很多地方都会用到,但,具体到每个接口,也许直接标注 `Sequence[int]` 会更简单。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个要不提个 PR 都替换了吧,直接用 Sequence[int] 就行了,这个应该是直接从 paddlepaddle-stubs 搬过来的,paddlepaddle-stubs 早期用的是 IntSequence = tuple[int, ...] | list[int],后来改成 IntSequence = Sequence[int] 也没删,但实际上没啥必要

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

提了个 PR 删了 PaddlePaddle/Paddle#67929

<div style="display: flex; justify-content: center">
<figure style="width: 80%;">
<img src="../images/type-hints-project/typing_module.png"/>
<figcaption>typing_module.pyi</figcaption>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里使用 .pyi 还是 .png 是怎么确定的?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.png ~ 这里写错了 ~

昨晚写的有点累,偷懒 figcaptionsrc 用同一个名字了,其实用中文会更好 ... ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我统一改一下吧

Copy link
Collaborator

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMeow 🐾

@SigureMo SigureMo added this pull request to the merge queue Sep 2, 2024
Merged via the queue into PFCCLab:main with commit d2471e2 Sep 2, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants