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