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] Add type annotations for paddle.jit #64867

Merged
merged 13 commits into from
Jun 5, 2024

Conversation

SigureMo
Copy link
Member

@SigureMo SigureMo commented Jun 3, 2024

PR Category

User Experience

PR Types

Improvements

Description

paddle.jit 模块添加类型提示,to_static API 的各种使用场景在 https://github.com/cattidea/paddlepaddle-stubs/blob/main/paddle-stubs/jit/api.pyihttps://github.com/cattidea/paddlepaddle-stubs/blob/main/tests/test_jit.py 进行了实验和验证

image

PCard-66972

@megemini

Copy link

paddle-bot bot commented Jun 3, 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.

_SeqLevel4[_T],
_SeqLevel5[_T],
_SeqLevel6[_T],
]
Copy link
Member Author

Choose a reason for hiding this comment

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

这是很久以前不支持递归类型定义才这样写的,现在测试过递归类型定义(31 行),mypy 和 pyright 都可以正常识别

gouzil
gouzil previously approved these changes Jun 5, 2024
zrr1999
zrr1999 previously approved these changes Jun 5, 2024
@SigureMo SigureMo dismissed stale reviews from zrr1999 and gouzil via 52a211c June 5, 2024 04:59
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

@@ -102,7 +111,7 @@ def convert_to_list(value, n, name, dtype=int):
return value_list


def is_sequence(seq):
def is_sequence(seq: Any) -> TypeGuard[typing.Sequence[Any]]:
Copy link
Contributor

Choose a reason for hiding this comment

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

这里是不是 bool?

Copy link
Member Author

Choose a reason for hiding this comment

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

可以了解下 TypeGuardTypeIs

@SigureMo SigureMo merged commit 0d686ca into PaddlePaddle:develop Jun 5, 2024
32 of 33 checks passed
@SigureMo SigureMo deleted the typing/jit branch June 5, 2024 09:15
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.

5 participants