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][PEP585 Upgrade][BUAA][111-120] Use standard collections for type hints for 10 files in python/paddle/ #67168

Merged
merged 7 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/paddle/reader/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
import random
import sys
import warnings
from collections.abc import Generator
Copy link
Member

Choose a reason for hiding this comment

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

这个在 type alias 里用了,不能改,运行时会挂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

收到!

from itertools import zip_longest
from queue import Queue
from threading import Thread
from typing import (
TYPE_CHECKING,
Any,
Callable,
Generator,
Sequence,
TypedDict,
TypeVar,
overload,
Expand All @@ -39,6 +38,7 @@
from paddle.base.reader import QUEUE_GET_TIMEOUT

if TYPE_CHECKING:
from collections.abc import Sequence

class _ComposeOptions(TypedDict):
check_alignment: NotRequired[bool]
Expand Down
4 changes: 3 additions & 1 deletion python/paddle/sparse/nn/functional/conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Literal, Sequence
from typing import TYPE_CHECKING, Literal

__all__ = []

Expand All @@ -27,6 +27,8 @@
from ...binary import add

if TYPE_CHECKING:
from collections.abc import Sequence

from paddle import Tensor
from paddle._typing import (
DataLayout2D,
Expand Down
4 changes: 3 additions & 1 deletion python/paddle/sparse/nn/layer/conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Literal, Sequence
from typing import TYPE_CHECKING, Literal

import numpy as np

Expand All @@ -26,6 +26,8 @@
from .. import functional as F

if TYPE_CHECKING:
from collections.abc import Sequence

from paddle import Tensor
from paddle._typing import (
ParamAttrLike,
Expand Down
4 changes: 3 additions & 1 deletion python/paddle/sparse/unary.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Sequence
from typing import TYPE_CHECKING

import numpy as np

Expand All @@ -31,6 +31,8 @@
from paddle.framework import LayerHelper

if TYPE_CHECKING:
from collections.abc import Sequence

from paddle import Tensor
from paddle._typing import DTypeLike, ShapeLike

Expand Down
5 changes: 4 additions & 1 deletion python/paddle/tensor/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Define functions about array.
from __future__ import annotations

from typing import Any, Sequence, TypeVar, overload
from typing import TYPE_CHECKING, Any, TypeVar, overload

import paddle
from paddle import _typing
Expand All @@ -25,6 +25,9 @@
from ..common_ops_import import Variable
from ..framework import LayerHelper, core, in_dynamic_mode

if TYPE_CHECKING:
from collections.abc import Sequence

__all__ = []
T = TypeVar("T")

Expand Down
4 changes: 3 additions & 1 deletion python/paddle/tensor/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import math
import re
from typing import TYPE_CHECKING, Any, Sequence, overload
from typing import TYPE_CHECKING, Any, overload

import numpy as np
import numpy.typing as npt
Expand Down Expand Up @@ -48,6 +48,8 @@
)

if TYPE_CHECKING:
from collections.abc import Sequence

from paddle._typing import (
DTypeLike,
NestedNumbericSequence,
Expand Down
4 changes: 3 additions & 1 deletion python/paddle/tensor/einsum.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import itertools
import re
import string
from typing import TYPE_CHECKING, NamedTuple, Sequence
from typing import TYPE_CHECKING, NamedTuple

import numpy as np
import opt_einsum
Expand All @@ -35,6 +35,8 @@
)

if TYPE_CHECKING:
from collections.abc import Sequence

from paddle import Tensor

__all__ = []
Expand Down
4 changes: 3 additions & 1 deletion python/paddle/tensor/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
from __future__ import annotations

from typing import TYPE_CHECKING, Literal, Sequence, overload
from typing import TYPE_CHECKING, Literal, overload

import numpy as np
from typing_extensions import TypeAlias
Expand Down Expand Up @@ -42,6 +42,8 @@
from .math import _get_reduce_axis

if TYPE_CHECKING:
from collections.abc import Sequence

from paddle import Tensor

_POrder: TypeAlias = Literal['fro', 'nuc']
Expand Down
4 changes: 3 additions & 1 deletion python/paddle/tensor/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from __future__ import annotations

import math
from typing import TYPE_CHECKING, Any, Callable, Literal, Sequence, overload
from typing import TYPE_CHECKING, Any, Literal, overload

import numpy as np

Expand Down Expand Up @@ -43,6 +43,8 @@
from .creation import _complex_to_real_dtype, _real_to_complex_dtype, zeros

if TYPE_CHECKING:
from collections.abc import Callable, Sequence

from paddle import Tensor
from paddle._typing import (
DTypeLike,
Expand Down