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][C-132,C-133,C-134] Add type annotations for python/paddle/nn/{clip,decode,initializer/lazy_init}.py #67031

Merged
merged 2 commits into from
Aug 6, 2024

Conversation

megemini
Copy link
Contributor

@megemini megemini commented Aug 5, 2024

PR Category

User Experience

PR Types

Improvements

Description

类型标注:

  • python/paddle/nn/clip.py
  • python/paddle/nn/decode.py
  • python/paddle/nn/initializer/lazy_init.py

Related links

@SigureMo @megemini

Copy link

paddle-bot bot commented Aug 5, 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.

@@ -129,5 +133,5 @@ def __enter__(self):
"""
lazy_init_helper().enable()

def __exit__(self, *args, **kwargs):
def __exit__(self, *args: object, **kwargs: Any) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

这俩为啥一个 object 一个 Any

这里可以改成 __exit__ 的标准签名么 https://stackoverflow.com/questions/58808055/what-are-the-python-builtin-exit-argument-types

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这俩为啥一个 object 一个 Any

我也想知道啊 ... ...

ruff.....................................................................Failed
- hook id: ruff
- exit code: 1
- files were modified by this hook

Found 1 error (1 fixed, 0 remaining).

这里可以改成 __exit__ 的标准签名么 https://stackoverflow.com/questions/58808055/what-are-the-python-builtin-exit-argument-types

我改一下吧,看看有木有问题 ~

Copy link
Member

Choose a reason for hiding this comment

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

image

https://docs.astral.sh/ruff/rules/bad-exit-annotation/

好像是个 undocumented behavior,按照标准签名来吧,这个肯定没问题

@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Aug 6, 2024
Copy link
Member

@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 merged commit 84d0524 into PaddlePaddle:develop Aug 6, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants