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][B-92] Add type annotations for python/paddle/batch.py #66295

Merged
merged 12 commits into from
Jul 23, 2024

Conversation

Caogration
Copy link
Contributor

PR Category

User Experience

PR Types

Improvements

Description

类型标注:

  • python/paddle/batch.py

Related links

@SigureMo @megemini

Copy link

paddle-bot bot commented Jul 20, 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

@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.

这已经是第三次提示了,按照 PR-CI-Codestyle-Check 报错提示运行 pre-commit

python/paddle/batch.py Outdated Show resolved Hide resolved

if TYPE_CHECKING:
from types import ModuleType
Copy link
Member

Choose a reason for hiding this comment

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

这是干啥用的?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这是没有用的,在新的提交中已经将其删除。

python/paddle/batch.py Outdated Show resolved Hide resolved
@SigureMo SigureMo changed the title [Typing][B-92] Add type annotations for python/paddle/batch.py [Typing][B-92] Add type annotations for python/paddle/batch.py Jul 20, 2024
@SigureMo
Copy link
Member

这已经是第三次提示了,按照 PR-CI-Codestyle-Check 报错提示运行 pre-commit

喔,抱歉看错人了,这是第一次 😂

Comment on lines 26 to 27
reader: Generator[T, None, None], batch_size: int, drop_last: bool = False
) -> Generator[List[T], None, None]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
reader: Generator[T, None, None], batch_size: int, drop_last: bool = False
) -> Generator[List[T], None, None]:
reader: Callable[[], Generator[_T, None, None]], batch_size: int, drop_last: bool = False
) -> Callable[[], Generator[list[_T], None, None]]:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Caogration and others added 3 commits July 22, 2024 09:30
Co-authored-by: Nyakku Shigure <sigure.qaq@gmail.com>
Co-authored-by: Nyakku Shigure <sigure.qaq@gmail.com>
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.

  1. pre-commit 仍然没跑
  2. 输入输出类型不对,没有按照 @megemini 的提示修改,可以参考 [Typing][B-93] Add type annotations for python/paddle/reader/decorator.py #66305 定义一个 TypeAlias


def batch(reader, batch_size, drop_last=False):
def batch(
reader: Generator[T, None, None], batch_size: int, drop_last: bool = False
Copy link
Member

Choose a reason for hiding this comment

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

上面定义了 _T,这里肯定也要改啊

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@luotao1 luotao1 added the HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 label Jul 22, 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 483d9d9 into PaddlePaddle:develop Jul 23, 2024
31 checks passed
@Caogration Caogration deleted the Type_Hints_of_B-92 branch July 23, 2024 06:50
inaomIIsfarell pushed a commit to inaomIIsfarell/Paddle that referenced this pull request Jul 31, 2024
…dlePaddle#66295)



---------

Co-authored-by: Nyakku Shigure <sigure.qaq@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants