From 13af28ba9c6fc4f737e7957b41734c3202af5096 Mon Sep 17 00:00:00 2001 From: Caogration <120171783+Caogration@users.noreply.github.com> Date: Sat, 20 Jul 2024 12:11:48 +0800 Subject: [PATCH 01/12] Update batch.py --- python/paddle/batch.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/python/paddle/batch.py b/python/paddle/batch.py index 98e5a6a14545a7..e7bd70c61de123 100644 --- a/python/paddle/batch.py +++ b/python/paddle/batch.py @@ -12,10 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -__all__ = [] +from __future__ import annotations + +from typing import TYPE_CHECKING, Generator, List, TypeVar +if TYPE_CHECKING: + from types import ModuleType + +T = TypeVar('T') +__all__ = [] -def batch(reader, batch_size, drop_last=False): +def batch( + reader: Generator[T, None, None], batch_size: int, drop_last: bool = False +) -> Generator[List[T], None, None]: """ This operator creates a batched reader which combines the data from the input reader to batched data. From 608ec366d464400ca8992de80a3f25ec66ec51f9 Mon Sep 17 00:00:00 2001 From: Caogration <120171783+Caogration@users.noreply.github.com> Date: Mon, 22 Jul 2024 09:30:18 +0800 Subject: [PATCH 02/12] Update python/paddle/batch.py Co-authored-by: Nyakku Shigure --- python/paddle/batch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle/batch.py b/python/paddle/batch.py index e7bd70c61de123..81f79bdebaa4fb 100644 --- a/python/paddle/batch.py +++ b/python/paddle/batch.py @@ -19,7 +19,7 @@ if TYPE_CHECKING: from types import ModuleType -T = TypeVar('T') +_T = TypeVar('_T') __all__ = [] def batch( From 0ad3ad8f9566448cbbc642a7157e41210913a4a2 Mon Sep 17 00:00:00 2001 From: Caogration <120171783+Caogration@users.noreply.github.com> Date: Mon, 22 Jul 2024 09:30:32 +0800 Subject: [PATCH 03/12] Update python/paddle/batch.py Co-authored-by: Nyakku Shigure --- python/paddle/batch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle/batch.py b/python/paddle/batch.py index 81f79bdebaa4fb..d5ea3e70da3df2 100644 --- a/python/paddle/batch.py +++ b/python/paddle/batch.py @@ -24,7 +24,7 @@ def batch( reader: Generator[T, None, None], batch_size: int, drop_last: bool = False -) -> Generator[List[T], None, None]: +) -> Generator[list[T], None, None]: """ This operator creates a batched reader which combines the data from the input reader to batched data. From f9d75f6b31fe215c574068ff9bf91519db1c71f1 Mon Sep 17 00:00:00 2001 From: Caogration <120171783+Caogration@users.noreply.github.com> Date: Mon, 22 Jul 2024 09:34:38 +0800 Subject: [PATCH 04/12] Delete unnecessary part of python/paddle/batch.py --- python/paddle/batch.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/python/paddle/batch.py b/python/paddle/batch.py index d5ea3e70da3df2..1440ab1a454d8f 100644 --- a/python/paddle/batch.py +++ b/python/paddle/batch.py @@ -16,9 +16,6 @@ from typing import TYPE_CHECKING, Generator, List, TypeVar -if TYPE_CHECKING: - from types import ModuleType - _T = TypeVar('_T') __all__ = [] From cf33d99f8e251ffcad581080aa50d3894b1c2c48 Mon Sep 17 00:00:00 2001 From: Caogration <120171783+Caogration@users.noreply.github.com> Date: Mon, 22 Jul 2024 14:54:08 +0800 Subject: [PATCH 05/12] Update batch.py with pre-commit of CI --- python/paddle/batch.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/paddle/batch.py b/python/paddle/batch.py index 1440ab1a454d8f..a0921cf9a1bafa 100644 --- a/python/paddle/batch.py +++ b/python/paddle/batch.py @@ -14,14 +14,15 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Generator, List, TypeVar +from typing import Generator, TypeVar _T = TypeVar('_T') __all__ = [] + def batch( - 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]]: """ This operator creates a batched reader which combines the data from the input reader to batched data. From ad4bd65213b12f4f563d81ef563b5e2dc1026d35 Mon Sep 17 00:00:00 2001 From: Caogration <120171783+Caogration@users.noreply.github.com> Date: Mon, 22 Jul 2024 15:50:48 +0800 Subject: [PATCH 06/12] Update batch.py with pre-commit of CI --- python/paddle/batch.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/paddle/batch.py b/python/paddle/batch.py index a0921cf9a1bafa..f93965b3c0db5e 100644 --- a/python/paddle/batch.py +++ b/python/paddle/batch.py @@ -21,7 +21,9 @@ def batch( - reader: Callable[[], Generator[_T, None, None]], batch_size: int, drop_last: bool = False + reader: Callable[[], Generator[_T, None, None]], + batch_size: int, + drop_last: bool = False ) -> Callable[[], Generator[list[_T], None, None]]: """ This operator creates a batched reader which combines the data from the From ddb07626e14696e30c0414e50e2ecdcbe265d0dc Mon Sep 17 00:00:00 2001 From: Caogration <120171783+Caogration@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:02:45 +0800 Subject: [PATCH 07/12] Update batch.py with a "," to fill pre-commit --- python/paddle/batch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle/batch.py b/python/paddle/batch.py index f93965b3c0db5e..43ea8a206efa73 100644 --- a/python/paddle/batch.py +++ b/python/paddle/batch.py @@ -23,7 +23,7 @@ def batch( reader: Callable[[], Generator[_T, None, None]], batch_size: int, - drop_last: bool = False + drop_last: bool = False, ) -> Callable[[], Generator[list[_T], None, None]]: """ This operator creates a batched reader which combines the data from the From a0aaf8262b700f8d3b91b2611566641027c67a08 Mon Sep 17 00:00:00 2001 From: Caogration <120171783+Caogration@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:16:34 +0800 Subject: [PATCH 08/12] Update batch.py with import Callable from typeing --- python/paddle/batch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/paddle/batch.py b/python/paddle/batch.py index 43ea8a206efa73..b4eefa79103164 100644 --- a/python/paddle/batch.py +++ b/python/paddle/batch.py @@ -14,7 +14,7 @@ from __future__ import annotations -from typing import Generator, TypeVar +from typing import Callable, Generator, TypeVar _T = TypeVar('_T') __all__ = [] @@ -24,7 +24,7 @@ def batch( reader: Callable[[], Generator[_T, None, None]], batch_size: int, drop_last: bool = False, -) -> Callable[[], Generator[list[_T], None, None]]: +) -> Callable[[], Generator[List[_T], None, None]]: """ This operator creates a batched reader which combines the data from the input reader to batched data. From e2664361894f0501e72bd2ef6af3473d34febeac Mon Sep 17 00:00:00 2001 From: Caogration <120171783+Caogration@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:27:29 +0800 Subject: [PATCH 09/12] Update batch.py with import List from typeing --- python/paddle/batch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle/batch.py b/python/paddle/batch.py index b4eefa79103164..9acfd0e17c6877 100644 --- a/python/paddle/batch.py +++ b/python/paddle/batch.py @@ -14,7 +14,7 @@ from __future__ import annotations -from typing import Callable, Generator, TypeVar +from typing import List, Callable, Generator, TypeVar _T = TypeVar('_T') __all__ = [] From 9ed6afcc2328f9c89bcf60643b8e66ba8a7b17f7 Mon Sep 17 00:00:00 2001 From: Caogration <120171783+Caogration@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:14:30 +0800 Subject: [PATCH 10/12] Update batch.py with import subsequence --- python/paddle/batch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle/batch.py b/python/paddle/batch.py index 9acfd0e17c6877..953a5d89f9836e 100644 --- a/python/paddle/batch.py +++ b/python/paddle/batch.py @@ -14,7 +14,7 @@ from __future__ import annotations -from typing import List, Callable, Generator, TypeVar +from typing import Callable, Generator, List, TypeVar _T = TypeVar('_T') __all__ = [] From 24d594c25fd11318eac2e90a1f674e08f7182b34 Mon Sep 17 00:00:00 2001 From: Caogration <120171783+Caogration@users.noreply.github.com> Date: Mon, 22 Jul 2024 18:07:50 +0800 Subject: [PATCH 11/12] Update batch.py with list in little form --- python/paddle/batch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle/batch.py b/python/paddle/batch.py index 953a5d89f9836e..eeca997e0b04e4 100644 --- a/python/paddle/batch.py +++ b/python/paddle/batch.py @@ -24,7 +24,7 @@ def batch( reader: Callable[[], Generator[_T, None, None]], batch_size: int, drop_last: bool = False, -) -> Callable[[], Generator[List[_T], None, None]]: +) -> Callable[[], Generator[list[_T], None, None]]: """ This operator creates a batched reader which combines the data from the input reader to batched data. From 2f6d562e17ec71fa06e965fed175e9ff90557592 Mon Sep 17 00:00:00 2001 From: Caogration <120171783+Caogration@users.noreply.github.com> Date: Mon, 22 Jul 2024 18:18:57 +0800 Subject: [PATCH 12/12] Update batch.py with deleting List imported --- python/paddle/batch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle/batch.py b/python/paddle/batch.py index eeca997e0b04e4..be0cfa5e00ab25 100644 --- a/python/paddle/batch.py +++ b/python/paddle/batch.py @@ -14,7 +14,7 @@ from __future__ import annotations -from typing import Callable, Generator, List, TypeVar +from typing import Callable, Generator, TypeVar _T = TypeVar('_T') __all__ = []