From 888b8b6b2a4ab074ab4da4a92ad90ba034a5a4bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Tue, 28 Mar 2023 10:36:04 +0800 Subject: [PATCH] [CodeStyle][PLC0414] remove self-alias and some discussion (#52122) --- pyproject.toml | 2 +- python/paddle/__init__.py | 2 +- python/paddle/autograd/__init__.py | 4 ++-- .../fleet/meta_optimizers/parameter_server_optimizer.py | 4 +--- python/paddle/distribution/gumbel.py | 2 +- python/paddle/distribution/laplace.py | 2 +- python/paddle/fluid/tests/unittests/ps/ps_dnn_trainer.py | 2 +- python/paddle/fluid/tests/unittests/test_get_set_flags.py | 2 +- .../fluid/tests/unittests/test_global_var_getter_setter.py | 2 +- python/paddle/incubate/autograd/primx.py | 2 +- python/paddle/incubate/autograd/utils.py | 2 +- .../fleet/parameter_server/distribute_transpiler/__init__.py | 2 +- setup.py | 2 +- 13 files changed, 14 insertions(+), 16 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ab849770c1c..68887b9df08 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -120,7 +120,7 @@ select = [ # "B904", # Pylint - # "PLC0414", + "PLC0414", # "PLC1901", "PLC3002", "PLE0100", diff --git a/python/paddle/__init__.py b/python/paddle/__init__.py index d6c6a150cad..87ff8e39ebe 100755 --- a/python/paddle/__init__.py +++ b/python/paddle/__init__.py @@ -42,7 +42,7 @@ from .fluid.lazy_init import LazyGuard # noqa: F401 from .framework.dtype import iinfo # noqa: F401 from .framework.dtype import finfo # noqa: F401 -from .framework.dtype import dtype as dtype # noqa: F401 +from .framework.dtype import dtype # noqa: F401 from .framework.dtype import uint8 # noqa: F401 from .framework.dtype import int8 # noqa: F401 from .framework.dtype import int16 # noqa: F401 diff --git a/python/paddle/autograd/__init__.py b/python/paddle/autograd/__init__.py index f5435b081e3..16dbef6ae44 100644 --- a/python/paddle/autograd/__init__.py +++ b/python/paddle/autograd/__init__.py @@ -19,8 +19,8 @@ from ..fluid.dygraph.base import is_grad_enabled # noqa: F401 from ..fluid.dygraph.base import set_grad_enabled # noqa: F401 from . import backward_mode # noqa: F401 from .backward_mode import backward # noqa: F401 -from .py_layer import PyLayer as PyLayer # noqa: F401 -from .py_layer import PyLayerContext as PyLayerContext # noqa: F401 +from .py_layer import PyLayer # noqa: F401 +from .py_layer import PyLayerContext # noqa: F401 from .saved_tensors_hooks import saved_tensors_hooks __all__ = [ # noqa diff --git a/python/paddle/distributed/fleet/meta_optimizers/parameter_server_optimizer.py b/python/paddle/distributed/fleet/meta_optimizers/parameter_server_optimizer.py index ec3472a7b69..a897760d41f 100644 --- a/python/paddle/distributed/fleet/meta_optimizers/parameter_server_optimizer.py +++ b/python/paddle/distributed/fleet/meta_optimizers/parameter_server_optimizer.py @@ -371,9 +371,7 @@ class ParameterServerOptimizer(MetaOptimizerBase): _origin_main_program = loss.block.program _origin_startup_program = startup_program - from paddle.incubate.distributed.fleet.parameter_server.ir import ( - public as public, - ) + from paddle.incubate.distributed.fleet.parameter_server.ir import public compiled_config = public.CompileTimeStrategy( _origin_main_program, diff --git a/python/paddle/distribution/gumbel.py b/python/paddle/distribution/gumbel.py index 067f87ca837..7513046212c 100644 --- a/python/paddle/distribution/gumbel.py +++ b/python/paddle/distribution/gumbel.py @@ -19,7 +19,7 @@ import numpy as np import paddle from paddle.distribution.transformed_distribution import TransformedDistribution -from paddle.fluid import framework as framework +from paddle.fluid import framework class Gumbel(TransformedDistribution): diff --git a/python/paddle/distribution/laplace.py b/python/paddle/distribution/laplace.py index 5c047aebfd9..fee7335538e 100644 --- a/python/paddle/distribution/laplace.py +++ b/python/paddle/distribution/laplace.py @@ -18,7 +18,7 @@ import numpy as np import paddle from paddle.distribution import distribution -from paddle.fluid import framework as framework +from paddle.fluid import framework class Laplace(distribution.Distribution): diff --git a/python/paddle/fluid/tests/unittests/ps/ps_dnn_trainer.py b/python/paddle/fluid/tests/unittests/ps/ps_dnn_trainer.py index 96f00f81121..2b28aa1c687 100755 --- a/python/paddle/fluid/tests/unittests/ps/ps_dnn_trainer.py +++ b/python/paddle/fluid/tests/unittests/ps/ps_dnn_trainer.py @@ -445,7 +445,7 @@ class DnnTrainer: "entering run {} - old".format(str(config["applied_pass_name"])) ) from paddle.incubate.distributed.fleet.parameter_server.ir import ( - public as public, + public, ) dist_strategy = get_distributed_strategy(user_defined_strategy) diff --git a/python/paddle/fluid/tests/unittests/test_get_set_flags.py b/python/paddle/fluid/tests/unittests/test_get_set_flags.py index 268c13aad40..8b30db14333 100644 --- a/python/paddle/fluid/tests/unittests/test_get_set_flags.py +++ b/python/paddle/fluid/tests/unittests/test_get_set_flags.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest as unittest +import unittest from paddle import fluid diff --git a/python/paddle/fluid/tests/unittests/test_global_var_getter_setter.py b/python/paddle/fluid/tests/unittests/test_global_var_getter_setter.py index b6650e659e1..3da1e85dc22 100644 --- a/python/paddle/fluid/tests/unittests/test_global_var_getter_setter.py +++ b/python/paddle/fluid/tests/unittests/test_global_var_getter_setter.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest as unittest +import unittest from paddle import fluid diff --git a/python/paddle/incubate/autograd/primx.py b/python/paddle/incubate/autograd/primx.py index 920ca699d91..352101a7fd1 100644 --- a/python/paddle/incubate/autograd/primx.py +++ b/python/paddle/incubate/autograd/primx.py @@ -17,7 +17,7 @@ import typing from collections import OrderedDict import paddle -from paddle.fluid import framework as framework +from paddle.fluid import framework from paddle.fluid.core import prim_config from paddle.fluid.framework import Operator, default_main_program from paddle.incubate.autograd.utils import as_tensors diff --git a/python/paddle/incubate/autograd/utils.py b/python/paddle/incubate/autograd/utils.py index 233ad3c7f2d..e79c27f30e1 100644 --- a/python/paddle/incubate/autograd/utils.py +++ b/python/paddle/incubate/autograd/utils.py @@ -15,7 +15,7 @@ import typing import paddle import paddle.framework.dtype as dtypes -from paddle.fluid import framework as framework +from paddle.fluid import framework from .phi_ops_map import op_info, op_map diff --git a/python/paddle/incubate/distributed/fleet/parameter_server/distribute_transpiler/__init__.py b/python/paddle/incubate/distributed/fleet/parameter_server/distribute_transpiler/__init__.py index f50e2e798ba..21accdb344a 100644 --- a/python/paddle/incubate/distributed/fleet/parameter_server/distribute_transpiler/__init__.py +++ b/python/paddle/incubate/distributed/fleet/parameter_server/distribute_transpiler/__init__.py @@ -75,7 +75,7 @@ from paddle.incubate.distributed.fleet.parameter_server.ir import ( pserver_pass as server, ) from paddle.incubate.distributed.fleet.parameter_server.ir import ( - public as public, + public, ) diff --git a/setup.py b/setup.py index 1435065aa90..87c223f42b4 100644 --- a/setup.py +++ b/setup.py @@ -1485,7 +1485,7 @@ def main(): else: env_dict_path = TOP_DIR + "/build/python/" sys.path.insert(1, env_dict_path) - from env_dict import env_dict as env_dict + from env_dict import env_dict global env_dict global paddle_binary_dir, paddle_source_dir -- GitLab