Skip to content

Commit da4ffb9

Browse files
authored
[Typing][A-69] Add type annotations for LR Schedulers (PaddlePaddle#65209)
1 parent 02be1a8 commit da4ffb9

File tree

3 files changed

+270
-122
lines changed

3 files changed

+270
-122
lines changed

python/paddle/_typing/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444

4545
# Shape
4646
from .shape import (
47-
DynamicShapeLike as DynamicShapeLike,
4847
ShapeLike as ShapeLike,
4948
Size1 as Size1,
5049
Size2 as Size2,

python/paddle/_typing/shape.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@
1313
# limitations under the License.
1414
from __future__ import annotations
1515

16-
from typing import TYPE_CHECKING, List, Tuple, Union
16+
from typing import TYPE_CHECKING, List, Sequence, Tuple, Union
1717

1818
from typing_extensions import TypeAlias
1919

2020
if TYPE_CHECKING:
2121
from .. import Tensor
2222

23-
DynamicShapeLike: TypeAlias = Union[
24-
Tuple[Union[int, "Tensor", None], ...],
25-
List[Union[int, "Tensor", None]],
23+
_DynamicShapeLike: TypeAlias = Union[
24+
Sequence[Union[int, "Tensor", None]],
2625
"Tensor",
2726
]
2827

2928

30-
ShapeLike: TypeAlias = Union[
31-
Tuple[int, ...],
32-
List[int],
29+
_StaticShapeLike: TypeAlias = Union[
30+
Sequence[int],
3331
"Tensor",
3432
]
3533

34+
ShapeLike: TypeAlias = Union[_DynamicShapeLike, _StaticShapeLike]
35+
3636

3737
# for size parameters, eg, kernel_size, stride ...
3838
Size1: TypeAlias = Union[int, Tuple[int], List[int]]

0 commit comments

Comments
 (0)