From a5ce223cc58d69014a98f7d3d417d0880467538b Mon Sep 17 00:00:00 2001 From: Nyakku Shigure Date: Tue, 11 Oct 2022 16:50:18 +0800 Subject: [PATCH] [CodeStyle][F401] remove unused imports in python/paddle (#46731) --- python/paddle/_C_ops.py | 1 - python/paddle/check_import_scipy.py | 2 +- python/paddle/common_ops_import.py | 27 +++++++++++------------- python/paddle/fft.py | 2 +- python/paddle/nn/functional/extension.py | 3 +-- python/paddle/signal.py | 4 +--- python/paddle/tensor/einsum.py | 2 -- python/paddle/tensor/linalg.py | 1 - python/paddle/tensor/math.py | 1 - python/paddle/tensor/search.py | 3 +-- 10 files changed, 17 insertions(+), 29 deletions(-) diff --git a/python/paddle/_C_ops.py b/python/paddle/_C_ops.py index aa501051e73..423d1b12536 100644 --- a/python/paddle/_C_ops.py +++ b/python/paddle/_C_ops.py @@ -13,7 +13,6 @@ # limitations under the License. from paddle.fluid import core -from .fluid import framework __all__ = [] diff --git a/python/paddle/check_import_scipy.py b/python/paddle/check_import_scipy.py index d6e13e2a670..9bbd061cb37 100644 --- a/python/paddle/check_import_scipy.py +++ b/python/paddle/check_import_scipy.py @@ -17,7 +17,7 @@ def check_import_scipy(OsName): print_info = "" if OsName == 'nt': try: - import scipy.io as scio + import scipy.io as scio # noqa: F401 except ImportError as e: print_info = str(e) if (len(print_info) > 0): diff --git a/python/paddle/common_ops_import.py b/python/paddle/common_ops_import.py index d8fdac59df4..00ef853b995 100644 --- a/python/paddle/common_ops_import.py +++ b/python/paddle/common_ops_import.py @@ -11,18 +11,15 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from six.moves import reduce -from paddle.fluid.layer_helper import LayerHelper -from paddle.fluid.param_attr import ParamAttr -from paddle.fluid.framework import convert_np_dtype_to_dtype_, _non_static_mode, _varbase_creator, in_dygraph_mode, _in_legacy_dygraph -from paddle.fluid.framework import device_guard, default_main_program, dygraph_only, _dygraph_tracer -from paddle.fluid.framework import OpProtoHolder, Variable -from paddle.fluid.initializer import Constant -from paddle.fluid.core import VarDesc -from paddle.fluid import core, dygraph_utils -from paddle.fluid.data_feeder import check_type, check_dtype, check_variable_and_dtype, convert_dtype -from paddle.fluid.layers import fill_constant, utils, scale -from paddle.tensor.layer_function_generator import templatedoc -import paddle.fluid as fluid -import numpy -import warnings +from paddle.fluid.layer_helper import LayerHelper # noqa: F401 +from paddle.fluid.param_attr import ParamAttr # noqa: F401 +from paddle.fluid.framework import convert_np_dtype_to_dtype_, _non_static_mode, _varbase_creator, in_dygraph_mode, _in_legacy_dygraph # noqa: F401 +from paddle.fluid.framework import device_guard, default_main_program, dygraph_only, _dygraph_tracer # noqa: F401 +from paddle.fluid.framework import OpProtoHolder, Variable # noqa: F401 +from paddle.fluid.initializer import Constant # noqa: F401 +from paddle.fluid.core import VarDesc # noqa: F401 +from paddle.fluid import core, dygraph_utils # noqa: F401 +from paddle.fluid.data_feeder import check_type, check_dtype, check_variable_and_dtype, convert_dtype # noqa: F401 +from paddle.fluid.layers import fill_constant, utils, scale # noqa: F401 +from paddle.tensor.layer_function_generator import templatedoc # noqa: F401 +import paddle.fluid as fluid # noqa: F401 diff --git a/python/paddle/fft.py b/python/paddle/fft.py index 161539aa9c4..b873d7b1df6 100644 --- a/python/paddle/fft.py +++ b/python/paddle/fft.py @@ -15,7 +15,7 @@ from typing import Sequence import numpy as np import paddle -from .tensor.attribute import is_complex, is_floating_point, is_integer +from .tensor.attribute import is_floating_point, is_integer from .tensor.creation import _real_to_complex_dtype, _complex_to_real_dtype from .fluid.framework import _in_legacy_dygraph, in_dygraph_mode from . import _C_ops, _legacy_C_ops diff --git a/python/paddle/nn/functional/extension.py b/python/paddle/nn/functional/extension.py index a7b21fd5ca9..682fa616d63 100644 --- a/python/paddle/nn/functional/extension.py +++ b/python/paddle/nn/functional/extension.py @@ -25,8 +25,7 @@ from paddle import in_dynamic_mode from paddle import _C_ops, _legacy_C_ops from ...fluid.framework import _non_static_mode, _in_legacy_dygraph, in_dygraph_mode from ...fluid.data_feeder import check_variable_and_dtype, check_type -from ...framework import core -from ...common_ops_import import convert_np_dtype_to_dtype_ +from ...framework import core, convert_np_dtype_to_dtype_ __all__ = [] diff --git a/python/paddle/signal.py b/python/paddle/signal.py index cc4e16b7dd0..535a388d0e0 100644 --- a/python/paddle/signal.py +++ b/python/paddle/signal.py @@ -12,11 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Optional - import paddle -from .tensor.attribute import is_complex, is_floating_point +from .tensor.attribute import is_complex from .fft import fft_r2c, fft_c2r, fft_c2c from .fluid.data_feeder import check_variable_and_dtype from .fluid.framework import _non_static_mode diff --git a/python/paddle/tensor/einsum.py b/python/paddle/tensor/einsum.py index 1ea3aa7cfa7..a4a4b3f959b 100644 --- a/python/paddle/tensor/einsum.py +++ b/python/paddle/tensor/einsum.py @@ -29,8 +29,6 @@ import collections import string import opt_einsum -from paddle.common_ops_import import dygraph_only - __all__ = [] diff --git a/python/paddle/tensor/linalg.py b/python/paddle/tensor/linalg.py index 3d087c771a3..d8e55c1de99 100644 --- a/python/paddle/tensor/linalg.py +++ b/python/paddle/tensor/linalg.py @@ -25,7 +25,6 @@ from .creation import full import paddle import warnings -from paddle.common_ops_import import core from paddle.common_ops_import import VarDesc from paddle import _C_ops, _legacy_C_ops diff --git a/python/paddle/tensor/math.py b/python/paddle/tensor/math.py index 12ee81a2469..12099726028 100644 --- a/python/paddle/tensor/math.py +++ b/python/paddle/tensor/math.py @@ -18,7 +18,6 @@ import numpy as np from paddle.common_ops_import import VarDesc from paddle.common_ops_import import dygraph_only -from paddle.common_ops_import import OpProtoHolder from paddle.common_ops_import import templatedoc from paddle.common_ops_import import dygraph_utils diff --git a/python/paddle/tensor/search.py b/python/paddle/tensor/search.py index 86d9326c39a..06813fbcf28 100644 --- a/python/paddle/tensor/search.py +++ b/python/paddle/tensor/search.py @@ -13,12 +13,11 @@ # limitations under the License. import numpy as np import paddle -from ..framework import LayerHelper +from ..framework import LayerHelper, convert_np_dtype_to_dtype_ from ..fluid.data_feeder import check_variable_and_dtype, check_type, check_dtype from ..fluid import layers from ..framework import core, in_dygraph_mode, _non_static_mode from ..fluid.framework import _in_legacy_dygraph -from paddle.common_ops_import import convert_np_dtype_to_dtype_ from paddle.common_ops_import import Variable from paddle.common_ops_import import VarDesc from paddle import _C_ops, _legacy_C_ops -- GitLab