未验证 提交 b0eec317 编写于 作者: N Nyakku Shigure 提交者: GitHub

[CodeStyle][py36-][E722] remove import handling for collections.abc in...

[CodeStyle][py36-][E722] remove import handling for collections.abc in different python versions (#48165)
上级 809516f6
......@@ -15,10 +15,7 @@
import paddle
from paddle.distribution import categorical, distribution
try:
from collections.abc import Iterable
except:
from collections import Iterable
from collections.abc import Iterable
class Multinomial(distribution.Distribution):
......
......@@ -26,10 +26,7 @@ from paddle.fluid.layers import (
tensor,
)
try:
from collections.abc import Iterable
except:
from collections import Iterable
from collections.abc import Iterable
class Normal(distribution.Distribution):
......
......@@ -26,10 +26,7 @@ import paddle.fluid
from .data_feeder import check_type
import warnings
try:
from collections.abc import Sequence
except:
from collections import Sequence
from collections.abc import Sequence
__all__ = [
'append_backward',
......
......@@ -18,10 +18,7 @@ import numpy as np
from ..framework import _non_static_mode
from .. import core, layers
try:
from collections.abc import Sequence, Mapping
except:
from collections import Sequence, Mapping
from collections.abc import Sequence, Mapping
def default_collate_fn(batch):
......
......@@ -16,10 +16,8 @@ import paddle
import numbers
import numpy as np
try:
from collections.abc import Sequence, Mapping
except:
from collections import Sequence, Mapping
from collections.abc import Sequence, Mapping
FIELD_PREFIX = "_paddle_field_"
......
......@@ -21,10 +21,7 @@ from paddle.fluid.dygraph.dygraph_to_static.utils import unwrap
from paddle.fluid.dygraph.dygraph_to_static.utils import ORIGI_INFO
from paddle.fluid.framework import Program
try:
from collections.abc import Sequence
except:
from collections import Sequence
from collections.abc import Sequence
class Location:
......
......@@ -59,6 +59,8 @@ from ..data_feeder import (
)
from paddle.utils import deprecated
from paddle import _C_ops, _legacy_C_ops
from collections.abc import Iterable
__all__ = [
'fc',
......@@ -6798,10 +6800,6 @@ def lod_append(x, level):
x = fluid.layers.data(name='x', shape=[6, 10], lod_level=1)
out = fluid.layers.lod_append(x, [1,1,1,1,1,1])
"""
try:
from collections.abc import Iterable
except:
from collections import Iterable
if x is None:
raise ValueError("Input(x) can't be None.")
if (not isinstance(level, Iterable)) and (not isinstance(level, Variable)):
......
......@@ -32,10 +32,7 @@ from ..framework import _non_static_mode
from ..param_attr import ParamAttr
from ..data_feeder import check_variable_and_dtype, check_type, check_dtype
try:
from collections.abc import Sequence
except:
from collections import Sequence
from collections.abc import Sequence
__all__ = [
'RNNCell',
......
......@@ -25,10 +25,7 @@ from ..data_feeder import (
from ..layer_helper import LayerHelper
from sys import version_info
try:
from collections.abc import Sequence
except:
from collections import Sequence
from collections.abc import Sequence
def convert_to_list(value, n, name, dtype=int):
......
......@@ -22,10 +22,7 @@ import paddle.fluid.core as core
from paddle.fluid.backward import _append_grad_suffix_, _as_list
from paddle.fluid.framework import _test_eager_guard
try:
from collections.abc import Sequence
except:
from collections import Sequence
from collections.abc import Sequence
def _product(t):
......
......@@ -49,10 +49,7 @@ from paddle.fluid.dygraph.io import (
)
from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX
try:
from collections.abc import Iterable
except:
from collections import Iterable
from collections.abc import Iterable
__all__ = []
......
......@@ -30,10 +30,7 @@ from paddle.framework import core
from paddle.static import default_startup_program
from paddle.static import program_guard
try:
from collections.abc import Sequence
except:
from collections import Sequence
from collections.abc import Sequence
__all__ = []
......
......@@ -12,22 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import math
import numbers
import collections
import numpy as np
import paddle
from paddle.utils import try_import
if sys.version_info < (3, 3):
Sequence = collections.Sequence
Iterable = collections.Iterable
else:
Sequence = collections.abc.Sequence
Iterable = collections.abc.Iterable
from collections.abc import Sequence, Iterable
__all__ = []
......
......@@ -12,20 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import numbers
import collections
from PIL import Image, ImageOps, ImageEnhance
import numpy as np
import paddle
if sys.version_info < (3, 3):
Sequence = collections.Sequence
Iterable = collections.Iterable
else:
Sequence = collections.abc.Sequence
Iterable = collections.abc.Iterable
from collections.abc import Sequence, Iterable
try:
# PIL version >= "9.1.0"
......
......@@ -13,23 +13,16 @@
# limitations under the License.
import math
import sys
import random
import numpy as np
import numbers
import collections
import traceback
import paddle
from . import functional as F
if sys.version_info < (3, 3):
Sequence = collections.Sequence
Iterable = collections.Iterable
else:
Sequence = collections.abc.Sequence
Iterable = collections.abc.Iterable
from collections.abc import Sequence, Iterable
__all__ = []
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册