From 82e630604c5d5801b829fc0a805e375979056ef7 Mon Sep 17 00:00:00 2001 From: ooo oo <106524776+ooooo-create@users.noreply.github.com> Date: Thu, 21 Sep 2023 11:12:43 +0800 Subject: [PATCH] [CodeStyle][task 11] enable Ruff F403 rule in `python/paddle/base/__init__.py` (#57501) --- pyproject.toml | 2 -- python/paddle/base/__init__.py | 47 +++++++++++++++++++++++--- python/paddle/base/core.py | 2 +- python/paddle/base/dygraph/__init__.py | 13 +++++-- python/paddle/base/io.py | 5 ++- 5 files changed, 58 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8dd98b65873aa..eca2770cb1b4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -109,8 +109,6 @@ ignore = [ "UP031", "C408", "UP030", - "F522", - "F403", "C405", "C417", "PLR0402", diff --git a/python/paddle/base/__init__.py b/python/paddle/base/__init__.py index 6eec276eee03d..acc6f9f51ae2f 100644 --- a/python/paddle/base/__init__.py +++ b/python/paddle/base/__init__.py @@ -34,17 +34,48 @@ # import all class inside framework into base module from . import framework -from .framework import * # noqa: F403 +from .framework import ( + Program, + default_startup_program, + default_main_program, + program_guard, + name_scope, + ipu_shard_guard, + set_ipu_shard, + cuda_places, + cpu_places, + xpu_places, + cuda_pinned_places, + in_dygraph_mode, + in_pir_mode, + in_dynamic_or_pir_mode, + is_compiled_with_cinn, + is_compiled_with_cuda, + is_compiled_with_rocm, + is_compiled_with_xpu, + Variable, + require_version, + device_guard, + set_flags, + get_flags, +) # import all class inside executor into base module from . import executor -from .executor import * # noqa: F403 +from .executor import ( + Executor, + global_scope, + scope_guard, +) from . import data_feed_desc -from .data_feed_desc import * # noqa: F403 +from .data_feed_desc import DataFeedDesc from . import dataset -from .dataset import * # noqa: F403 +from .dataset import ( + DatasetFactory, + InMemoryDataset, +) from . import trainer_desc @@ -72,7 +103,13 @@ from . import unique_name from . import compiler -from .compiler import * # noqa: F403 +from .compiler import ( + CompiledProgram, + ExecutionStrategy, + BuildStrategy, + IpuCompiledProgram, + IpuStrategy, +) from paddle.base.layers.math_op_patch import monkey_patch_variable from .dygraph.base import enable_dygraph, disable_dygraph from .dygraph.tensor_patch_methods import monkey_patch_tensor diff --git a/python/paddle/base/core.py b/python/paddle/base/core.py index df90a6ace8582..285a9f1b1a61b 100644 --- a/python/paddle/base/core.py +++ b/python/paddle/base/core.py @@ -278,7 +278,7 @@ def to_list(s): # assign tensor alias libpaddle.LoDTensor = libpaddle.Tensor - from .libpaddle import * + from .libpaddle import * # noqa: F403 from .libpaddle import ( # noqa: F401 __doc__, __file__, diff --git a/python/paddle/base/dygraph/__init__.py b/python/paddle/base/dygraph/__init__.py index 6355ca337b9f8..2ac4df711681c 100644 --- a/python/paddle/base/dygraph/__init__.py +++ b/python/paddle/base/dygraph/__init__.py @@ -13,10 +13,19 @@ # limitations under the License. from . import base -from .base import * # noqa: F403 +from .base import ( + no_grad, + no_grad_, + grad, + guard, + enable_dygraph, + disable_dygraph, + enabled, + to_variable, +) from . import tracer -from .tracer import * # noqa: F403 +from .tracer import Tracer __all__ = [] diff --git a/python/paddle/base/io.py b/python/paddle/base/io.py index a2c7d02ede349..55f5c072f4e27 100644 --- a/python/paddle/base/io.py +++ b/python/paddle/base/io.py @@ -17,7 +17,10 @@ from paddle.base.log_helper import get_logger from . import reader -from .reader import * +from .reader import ( # noqa: F401 + PyReader, + DataLoader, +) __all__ = reader.__all__