Skip to content

Conversation

SigureMo
Copy link
Member

@SigureMo SigureMo commented Jun 6, 2024

PR Category

User Experience

PR Types

Improvements

Description

为基础装饰器添加类型提示,以便支持类型推导,比如

@static_only
def data(name: str, shape: ShapeLike, dtype: DTypeLike | None = None, lod_level: int = 0) -> paddle.Tensor:

这里 static.data 原函数虽然标注了,但是公开的 API 是装饰后的,经过装饰后类型就没了,本 PR 修改了相关基础装饰器,确保公开 API 的类型签名是不变的

@megemini

Tip

仅类型提示 PR,不影响运行时

PCard-66972

Copy link

paddle-bot bot commented Jun 6, 2024

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Member Author

Choose a reason for hiding this comment

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

这个文件好像也得加到 setup.py 才能打包

@SigureMo SigureMo changed the title [Typing] Add type annotations for base decorators Add type annotations for base decorators Jun 12, 2024
Copy link
Contributor

@wanghuancoder wanghuancoder left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@Aurelius84 Aurelius84 left a comment

Choose a reason for hiding this comment

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

Great work!

@SigureMo SigureMo changed the title Add type annotations for base decorators [Typing] Add type annotations for base decorators Jun 13, 2024
@SigureMo SigureMo merged commit 3768840 into PaddlePaddle:develop Jun 13, 2024
@SigureMo SigureMo deleted the typing/decorators branch June 13, 2024 04:43
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