diff --git a/pyproject.toml b/pyproject.toml index 789f6a16a7274d..fe9dc1a8bbebb4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,7 +70,7 @@ select = [ "PLR0206", "PLR0402", "PLR1701", - # "PLR1711", # Confirmation required + "PLR1711", "PLR1722", "PLW3301", ] diff --git a/python/paddle/base/core.py b/python/paddle/base/core.py index add11e728ec8c9..df90a6ace8582d 100644 --- a/python/paddle/base/core.py +++ b/python/paddle/base/core.py @@ -507,7 +507,6 @@ def _set_prim_forward_blacklist(*args): raise TypeError("ops set in forward_blacklist must belong to str") else: prim_config["forward_blacklist"].add(item) - return def _set_prim_backward_blacklist(*args): @@ -516,7 +515,6 @@ def _set_prim_backward_blacklist(*args): if not isinstance(item, str): raise TypeError("all items in set must belong to string") _set_bwd_prim_blacklist(ops) - return def _set_prim_backward_enabled(value): diff --git a/python/paddle/base/incubate/checkpoint/auto_checkpoint.py b/python/paddle/base/incubate/checkpoint/auto_checkpoint.py index 63ed4eb41a9fbc..23239b692c9752 100644 --- a/python/paddle/base/incubate/checkpoint/auto_checkpoint.py +++ b/python/paddle/base/incubate/checkpoint/auto_checkpoint.py @@ -633,8 +633,6 @@ def _normal_yield(max_epoch_num): max_epoch_num = sys.maxint yield from range(0, max_epoch_num) - return - def train_epoch_range(max_epoch_num, save_checkpoint_inter=None): global g_acp_type diff --git a/python/paddle/base/layers/math_op_patch.py b/python/paddle/base/layers/math_op_patch.py index d03f3f580d2e34..06f384eae23d10 100644 --- a/python/paddle/base/layers/math_op_patch.py +++ b/python/paddle/base/layers/math_op_patch.py @@ -236,7 +236,6 @@ def place(self): warnings.warn( "Variable do not have 'place' interface for static graph mode, try not to use it. None will be returned." ) - return None def astype(self, dtype): """ diff --git a/python/paddle/check_import_scipy.py b/python/paddle/check_import_scipy.py index 473a4301813cdf..01e73bac42c343 100644 --- a/python/paddle/check_import_scipy.py +++ b/python/paddle/check_import_scipy.py @@ -26,4 +26,3 @@ def check_import_scipy(OsName): print_info + "\nplease download Visual C++ Redistributable from https://support.microsoft.com/en-us/topic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0" ) - return diff --git a/python/paddle/distributed/auto_parallel/static/operators/dist_default.py b/python/paddle/distributed/auto_parallel/static/operators/dist_default.py index cd967f23a0d905..93833651dd1855 100644 --- a/python/paddle/distributed/auto_parallel/static/operators/dist_default.py +++ b/python/paddle/distributed/auto_parallel/static/operators/dist_default.py @@ -92,8 +92,6 @@ def prim_operator_data_parallel_functor(ctx, src_op): op_attr.set_input_dims_mapping(grad_var.name, dims_mapping) ctx.set_op_dist_attr_for_program(allreduce_op, op_attr) - return - class DistributedDefault(DistributedOperatorImplContainer): def __init__(self, op_type): diff --git a/python/paddle/distributed/auto_tuner/recorder.py b/python/paddle/distributed/auto_tuner/recorder.py index ad8847c8a0dc6d..296f29ec25ffb8 100644 --- a/python/paddle/distributed/auto_tuner/recorder.py +++ b/python/paddle/distributed/auto_tuner/recorder.py @@ -46,7 +46,6 @@ def sort_metric(self, direction, metric_name) -> None: else float('inf'), reverse=False, ) - return def get_best(self, metric, direction) -> Tuple[dict, bool]: self.sort_metric(direction=direction, metric_name=metric) diff --git a/python/paddle/distributed/communication/stream/all_reduce.py b/python/paddle/distributed/communication/stream/all_reduce.py index 61ea16b769a7ad..af55b2bcae4387 100644 --- a/python/paddle/distributed/communication/stream/all_reduce.py +++ b/python/paddle/distributed/communication/stream/all_reduce.py @@ -68,8 +68,6 @@ def _all_reduce_in_static_mode(tensor, op, group, sync_op, use_calc_stream): attrs={'ring_id': ring_id, 'use_calc_stream': sync_op}, ) - return None - def all_reduce( tensor, op=ReduceOp.SUM, group=None, sync_op=True, use_calc_stream=False diff --git a/python/paddle/distributed/communication/stream/all_to_all.py b/python/paddle/distributed/communication/stream/all_to_all.py index 656986270805c9..d63456d6d83ddc 100644 --- a/python/paddle/distributed/communication/stream/all_to_all.py +++ b/python/paddle/distributed/communication/stream/all_to_all.py @@ -123,8 +123,6 @@ def _all_to_all_in_static_mode( paddle.split(out_tensor, nranks, 0) ) - return None - def alltoall( out_tensor_or_tensor_list, diff --git a/python/paddle/distributed/communication/stream/broadcast.py b/python/paddle/distributed/communication/stream/broadcast.py index 2f02012098ec9a..751a670a119ead 100644 --- a/python/paddle/distributed/communication/stream/broadcast.py +++ b/python/paddle/distributed/communication/stream/broadcast.py @@ -69,7 +69,6 @@ def _broadcast_in_static_mode( 'ring_id': ring_id, }, ) - return None def broadcast(tensor, src, group=None, sync_op=True, use_calc_stream=False): diff --git a/python/paddle/distributed/communication/stream/recv.py b/python/paddle/distributed/communication/stream/recv.py index cb93ce8a471558..8a55db44075906 100644 --- a/python/paddle/distributed/communication/stream/recv.py +++ b/python/paddle/distributed/communication/stream/recv.py @@ -59,7 +59,6 @@ def _recv_in_static_mode( 'use_calc_stream': sync_op, }, ) - return None def recv(tensor, src=0, group=None, sync_op=True, use_calc_stream=False): diff --git a/python/paddle/distributed/communication/stream/reduce.py b/python/paddle/distributed/communication/stream/reduce.py index 93c69a701879e8..6535d1a7bab720 100644 --- a/python/paddle/distributed/communication/stream/reduce.py +++ b/python/paddle/distributed/communication/stream/reduce.py @@ -73,7 +73,6 @@ def _reduce_in_static_mode( 'root_id': dst_rank_in_group, }, ) - return None def reduce( diff --git a/python/paddle/distributed/communication/stream/reduce_scatter.py b/python/paddle/distributed/communication/stream/reduce_scatter.py index 6b9d669469e8ec..117a4880d6f052 100644 --- a/python/paddle/distributed/communication/stream/reduce_scatter.py +++ b/python/paddle/distributed/communication/stream/reduce_scatter.py @@ -99,7 +99,6 @@ def _reduce_scatter_in_static_mode(tensor, tensor_or_tensor_list, group): 'nranks': nranks, }, ) - return None def reduce_scatter( diff --git a/python/paddle/distributed/communication/stream/scatter.py b/python/paddle/distributed/communication/stream/scatter.py index 84a03f44bdf3e6..9603ddd410a29e 100644 --- a/python/paddle/distributed/communication/stream/scatter.py +++ b/python/paddle/distributed/communication/stream/scatter.py @@ -129,8 +129,6 @@ def _scatter_in_static_mode( }, ) - return None - def scatter( tensor, diff --git a/python/paddle/distributed/communication/stream/send.py b/python/paddle/distributed/communication/stream/send.py index d90d180783c850..c04ba6b5736b71 100644 --- a/python/paddle/distributed/communication/stream/send.py +++ b/python/paddle/distributed/communication/stream/send.py @@ -58,7 +58,6 @@ def _send_in_static_mode( 'use_calc_stream': sync_op, }, ) - return None def send(tensor, dst=0, group=None, sync_op=True, use_calc_stream=False): diff --git a/python/paddle/distributed/communicator.py b/python/paddle/distributed/communicator.py index 613ee9c98d9998..d590e8a7b59bb2 100755 --- a/python/paddle/distributed/communicator.py +++ b/python/paddle/distributed/communicator.py @@ -229,14 +229,12 @@ def start_coordinator(self, self_endpoint, trainer_endpoints): self.communicator_.start_coordinator( self_endpoint, trainer_endpoints ) - return def save_fl_strategy(self, mp): if self.communicator_ is not None: self.communicator_.save_fl_strategy(mp) else: raise ValueError("self.communicator_ is null") - return def query_fl_clients_info(self): info_mp = {} diff --git a/python/paddle/distributed/fleet/base/role_maker.py b/python/paddle/distributed/fleet/base/role_maker.py index 870f818d177a9c..130a7a338a8981 100755 --- a/python/paddle/distributed/fleet/base/role_maker.py +++ b/python/paddle/distributed/fleet/base/role_maker.py @@ -497,7 +497,6 @@ def to_string(self): def _all_gather(self, input, comm_world="worker"): print("warning: RoleMakerBase does not have all gather worker.") - return None def _all_reduce(self, input, mode="sum", comm_world="worker"): """ @@ -507,7 +506,6 @@ def _all_reduce(self, input, mode="sum", comm_world="worker"): mode(str): "sum" or "min" or "max" """ print("warning: RoleMakerBase does not have all reduce worker.") - return None def _barrier(self, comm_world): """ diff --git a/python/paddle/distributed/fleet/launch_utils.py b/python/paddle/distributed/fleet/launch_utils.py index 41179c4ea8d8aa..2b48f29c570183 100755 --- a/python/paddle/distributed/fleet/launch_utils.py +++ b/python/paddle/distributed/fleet/launch_utils.py @@ -843,7 +843,6 @@ def direct_start(args): ] + args.training_script_args proc = subprocess.Popen(cmd) proc.wait() - return def get_custom_endpoints(origin_endpoints, offset=0): diff --git a/python/paddle/distributed/fleet/meta_optimizers/sharding/utils.py b/python/paddle/distributed/fleet/meta_optimizers/sharding/utils.py index 969531599917fd..44a584ac6d0b27 100755 --- a/python/paddle/distributed/fleet/meta_optimizers/sharding/utils.py +++ b/python/paddle/distributed/fleet/meta_optimizers/sharding/utils.py @@ -93,7 +93,6 @@ def check_broadcast(block): < last_sync_comm_op_idx ) assert last_sync_comm_op_idx < idx - return def check_allreduce_sum(block, shard, sharding_ring_id, dp_ring_id=-1): @@ -254,8 +253,6 @@ def check_allreduce_sum(block, shard, sharding_ring_id, dp_ring_id=-1): if idx_gradient_clip_allreduce != -1: assert idx_gradient_clip_allreduce > idx_last_grad_allreduce - return - def get_valid_op_role(block, insert_idx): """ @@ -284,7 +281,6 @@ def insert_sync_calc_op(block, insert_idx, calc_dep_vars): outputs={'Out': calc_dep_vars}, attrs={OP_ROLE_KEY: op_role}, ) - return def insert_sync_comm_op(block, insert_idx, ring_id, comm_dep_vars): @@ -339,7 +335,6 @@ def insert_fill_constant_ops(block, insert_idx, fill_constant_vars): OP_ROLE_KEY: op_role, }, ) - return def insert_cast_ops(block, insert_idx, cast_ops): @@ -359,7 +354,6 @@ def insert_cast_ops(block, insert_idx, cast_ops): OP_ROLE_KEY: op_role, }, ) - return def insert_allreduce_ops( @@ -873,8 +867,6 @@ def insert_broadcast_ops(block, insert_idx, ring_id, broadcast2root): }, ) - return - DtypeToSize = { core.VarDesc.VarType.FP16: 2, @@ -994,7 +986,6 @@ def add_sync_comm(program, sharding_ring_id): 'op_role': core.op_proto_and_checker_maker.OpRole.Forward, }, ) - return def save_persistables(exe, dirname, main_program, filename=None): @@ -1055,8 +1046,6 @@ def sharding_predicate(var): filename=None, ) - return - def append_naive_sync(block, sync_var, ring_id): # NOTE (JZ-LIANG) update this to use barrier sync for more elegent logic diff --git a/python/paddle/distributed/fleet/meta_optimizers/sharding_optimizer.py b/python/paddle/distributed/fleet/meta_optimizers/sharding_optimizer.py index 447c7f13077934..987e3eb1359178 100755 --- a/python/paddle/distributed/fleet/meta_optimizers/sharding_optimizer.py +++ b/python/paddle/distributed/fleet/meta_optimizers/sharding_optimizer.py @@ -980,7 +980,6 @@ def _split_program(self, block): ].desc.input_arg_names(), ) ) - return def _prune_main_program(self, block, shard, rings): """ @@ -1096,7 +1095,6 @@ def _prune_main_program(self, block, shard, rings): reserved_x.append(var_name) op.desc.set_input('X', reserved_x) block._sync_with_cpp() - return def _add_broadcast_allreduce(self, block): """ @@ -1665,8 +1663,6 @@ def _build_groups(self): logger.info(f"pure dp ring id: {self.dp_ring_id}") logger.info("#####" * 6) - return - def _recreate_not_persist_param_as_var(self): def recreate_not_persist_param_as_var(program): block = program.global_block() diff --git a/python/paddle/distributed/fleet/meta_parallel/sharding/group_sharded_stage3.py b/python/paddle/distributed/fleet/meta_parallel/sharding/group_sharded_stage3.py index 3b342778442c26..12c5ac37c8b10b 100644 --- a/python/paddle/distributed/fleet/meta_parallel/sharding/group_sharded_stage3.py +++ b/python/paddle/distributed/fleet/meta_parallel/sharding/group_sharded_stage3.py @@ -959,7 +959,6 @@ def _release_param( if offload: param.fw_storage = _device2cpu(param.fw_storage) - return def _wait_layer( diff --git a/python/paddle/distributed/fleet/utils/mix_precision_utils.py b/python/paddle/distributed/fleet/utils/mix_precision_utils.py index ead12379bb5a86..f6b04bbfda011e 100644 --- a/python/paddle/distributed/fleet/utils/mix_precision_utils.py +++ b/python/paddle/distributed/fleet/utils/mix_precision_utils.py @@ -67,7 +67,6 @@ def param_hook(tmp_grad): param.main_grad.add_(tmp_grad) tmp_grad._clear_data() - return None return param_hook diff --git a/python/paddle/distributed/passes/auto_parallel_sharding.py b/python/paddle/distributed/passes/auto_parallel_sharding.py index 44880cd6a3bfc3..1b08758ed1209e 100644 --- a/python/paddle/distributed/passes/auto_parallel_sharding.py +++ b/python/paddle/distributed/passes/auto_parallel_sharding.py @@ -1430,7 +1430,6 @@ def _insert_init_and_broadcast_op( broadcast_var_dist_attr.dims_mapping, dist_context, ) - return def _insert_reduce_op( diff --git a/python/paddle/distributed/passes/ps_trainer_pass.py b/python/paddle/distributed/passes/ps_trainer_pass.py index 8510b8b8a536c3..e93941b333bf48 100755 --- a/python/paddle/distributed/passes/ps_trainer_pass.py +++ b/python/paddle/distributed/passes/ps_trainer_pass.py @@ -1391,7 +1391,6 @@ def _insert_partA_communicate_op(self, block, idx): RPC_OP_ROLE_ATTR_NAME: RPC_OP_ROLE_ATTR_VALUE, }, ) - return def _insert_partB_communicate_op(self, block, idx): comm_info = f"backward_joint_{2}_{1}@fl_ps" @@ -1416,7 +1415,6 @@ def _insert_partB_communicate_op(self, block, idx): RPC_OP_ROLE_ATTR_NAME: RPC_OP_ROLE_ATTR_VALUE, }, ) - return def _create_var_for_block(self, vars, block): for var in vars: diff --git a/python/paddle/distributed/ps/coordinator.py b/python/paddle/distributed/ps/coordinator.py index 205151202ab96f..f433b58ae20dd2 100755 --- a/python/paddle/distributed/ps/coordinator.py +++ b/python/paddle/distributed/ps/coordinator.py @@ -246,7 +246,6 @@ def train_loop(self): def push_fl_client_info_sync(self, state_info): str_msg = self.__build_fl_client_info_desc(state_info) self._client_ptr.push_fl_client_info_sync(str_msg) - return def pull_fl_strategy(self): strategy_dict = {} diff --git a/python/paddle/distributed/ps/utils/ps_program_builder.py b/python/paddle/distributed/ps/utils/ps_program_builder.py index 8ba98a3707d99c..6d087c4ab493c2 100755 --- a/python/paddle/distributed/ps/utils/ps_program_builder.py +++ b/python/paddle/distributed/ps/utils/ps_program_builder.py @@ -125,7 +125,6 @@ def _build_pserver_programs(self): add_listen_and_serv_pass.apply( [self.attrs['_main_server']], [None], self.pass_ctx ) - return class NuPsProgramBuilder(PsProgramBuilder): @@ -174,8 +173,6 @@ def _build_trainer_programs(self): if self.launch_barrier and self.launch_barrier_flag: wait_server_ready(self.server_endpoints) - return - class CpuSyncPsProgramBuilder(PsProgramBuilder): def __init__(self, pass_ctx): @@ -226,8 +223,6 @@ def _build_trainer_programs(self): if self.launch_barrier and self.launch_barrier_flag: wait_server_ready(self.server_endpoints) - return - class CpuAsyncPsProgramBuilder(CpuSyncPsProgramBuilder): def __init__(self, pass_ctx): @@ -296,8 +291,6 @@ def _build_trainer_programs(self): if self.launch_barrier and self.launch_barrier_flag: wait_server_ready(self.server_endpoints) - return - class HeterAsyncPsProgramBuilder(PsProgramBuilder): def __init__(self, pass_ctx): @@ -355,8 +348,6 @@ def _build_trainer_programs(self): if self.launch_barrier and self.launch_barrier_flag: wait_server_ready(self.server_endpoints) - return - def _build_programs(self): if self.attrs['is_worker'] or self.attrs['is_heter_worker']: self._build_trainer_programs() @@ -458,8 +449,6 @@ def _build_trainer_programs(self): ], ) - return - def _build_pserver_programs(self): self.loss.block.program = self.attrs['_main_server'] diff --git a/python/paddle/incubate/distributed/fleet/role_maker.py b/python/paddle/incubate/distributed/fleet/role_maker.py index 920f04ac3fa734..c2c7d349f5623f 100644 --- a/python/paddle/incubate/distributed/fleet/role_maker.py +++ b/python/paddle/incubate/distributed/fleet/role_maker.py @@ -160,7 +160,6 @@ def all_gather(self, input): return a list of values """ print("warning: RoleMakerBase does not have all gather.") - return None def all_reduce_worker(self, input, output, mode="sum"): """ diff --git a/python/paddle/incubate/optimizer/recompute.py b/python/paddle/incubate/optimizer/recompute.py index f93de7b1beba56..8e16bf27a1b537 100644 --- a/python/paddle/incubate/optimizer/recompute.py +++ b/python/paddle/incubate/optimizer/recompute.py @@ -274,8 +274,6 @@ def _append_fill_constant_ops(self, startup_program): }, ) - return - def _insert_async_memcpy_op( self, insert_idx, src_varname, dst_varname, op_role, dst_place_type ): @@ -639,8 +637,6 @@ def _offload(self, loss, startup_program=None): # step 4. verify the correctness self._check_offload_fetch() - return - def backward( self, loss, diff --git a/python/paddle/jit/api.py b/python/paddle/jit/api.py index b1947e90177168..5799f740d147f0 100644 --- a/python/paddle/jit/api.py +++ b/python/paddle/jit/api.py @@ -821,7 +821,6 @@ def set_property(meta, key, val): meta.set_strings(key, val) else: raise ValueError(f"Note support val type: {type(val)}") - return with open(filename, 'wb') as f: meta = paddle.framework.core.Property() diff --git a/python/paddle/jit/dy2static/partial_program.py b/python/paddle/jit/dy2static/partial_program.py index 1f68cc71be5ff2..04255140ae9ca4 100644 --- a/python/paddle/jit/dy2static/partial_program.py +++ b/python/paddle/jit/dy2static/partial_program.py @@ -984,7 +984,6 @@ def set_stop_gradient(var_id, eager_tensor): var = self._outputs[var_id] assert isinstance(var, framework.Variable) eager_tensor.stop_gradient = var.stop_gradient - return None for idx, var in zip(self._outputs.var_ids, out_vars): set_stop_gradient(idx, var) diff --git a/python/paddle/jit/dy2static/utils.py b/python/paddle/jit/dy2static/utils.py index b66d97efa6e1c2..1bdf46629dfd03 100644 --- a/python/paddle/jit/dy2static/utils.py +++ b/python/paddle/jit/dy2static/utils.py @@ -326,7 +326,6 @@ def _delete_keywords_from(node): full_args_name = full_args[0] node.keywords = [k for k in node.keywords if k.arg in full_args_name] - return def to_static_api(dygraph_class): @@ -361,7 +360,6 @@ def _add_keywords_to(node, dygraph_api_name): for ast_keyword in node.keywords: if ast_keyword.arg == "input": ast_keyword.arg = "x" - return def to_static_ast(node, class_node): @@ -760,7 +758,6 @@ def transform(self): def _visit_If(self, node): assert isinstance(node, gast.If) self.visit(node.test) - return def _visit_For(self, node): assert isinstance(node, gast.For) @@ -801,7 +798,6 @@ def _visit_While(self, node): for child_node in gast.walk(node): if isinstance(child_node, (gast.Continue, gast.Break)): self._visit_break_continue(child_node) - return def _visit_break_continue(self, node): assert isinstance(node, (gast.Break, gast.Continue)) diff --git a/python/paddle/nn/layer/layers.py b/python/paddle/nn/layer/layers.py index c2b507e1a15c0d..2adab553cf21a8 100644 --- a/python/paddle/nn/layer/layers.py +++ b/python/paddle/nn/layer/layers.py @@ -71,8 +71,6 @@ def record_program_ops_pre_hook(layer, inputs): ) ) - return None - def set_op_customized_attrs_post_hook(layer, inputs, outputs): """ @@ -95,8 +93,6 @@ def set_op_customized_attrs_post_hook(layer, inputs, outputs): for hook_helper in layer._op_recorder.hooks: hook_helper.remove() - return None - def _scope_dist2single(dist_scope): mapping = { diff --git a/python/paddle/nn/utils/transform_parameters.py b/python/paddle/nn/utils/transform_parameters.py index c3f9562e544e86..7cb628565cff95 100644 --- a/python/paddle/nn/utils/transform_parameters.py +++ b/python/paddle/nn/utils/transform_parameters.py @@ -178,4 +178,3 @@ def vector_to_parameters(vec, parameters, name=None): for i, param in enumerate(parameters): _inplace_reshape_dygraph(param, origin_shapes[i]) - return diff --git a/python/paddle/optimizer/adam.py b/python/paddle/optimizer/adam.py index 7464e36e1cff60..a096c8afd12b97 100644 --- a/python/paddle/optimizer/adam.py +++ b/python/paddle/optimizer/adam.py @@ -716,7 +716,6 @@ def _append_optimize_multi_tensor_op( attrs=attrs, stop_gradient=True, ) - return None def _update_param_group(self, parameters): self._beta1 = parameters.get('beta1', self._default_dict['beta1']) diff --git a/python/paddle/optimizer/momentum.py b/python/paddle/optimizer/momentum.py index 36d09f00c0e61d..8269663f1c500c 100644 --- a/python/paddle/optimizer/momentum.py +++ b/python/paddle/optimizer/momentum.py @@ -537,7 +537,6 @@ def _append_optimize_multi_tensor_op( attrs=attrs, stop_gradient=True, ) - return None def _update_param_group(self, parameters): self._momentum = parameters.get( diff --git a/python/paddle/optimizer/optimizer.py b/python/paddle/optimizer/optimizer.py index 20f2fa970900e6..ca30dc3c17024e 100644 --- a/python/paddle/optimizer/optimizer.py +++ b/python/paddle/optimizer/optimizer.py @@ -1688,7 +1688,6 @@ def _declarative_step(self): ) params_grads = [(param, param.grad) for param in parameters] optimize_ops = self.apply_gradients(params_grads) - return @imperative_base.no_grad() @framework.non_static_only diff --git a/test/collective/collective_allreduce_api.py b/test/collective/collective_allreduce_api.py index e41d2568bad89d..ed398d698642d8 100644 --- a/test/collective/collective_allreduce_api.py +++ b/test/collective/collective_allreduce_api.py @@ -63,8 +63,6 @@ def all_reduce_new(tensor, reduce_type=str(dist.ReduceOp.SUM), group=None): attrs={'ring_id': ring_id, 'reduce_type': int(reduce_type)}, ) - return None - class TestCollectiveAllreduceAPI(TestCollectiveAPIRunnerBase): def __init__(self): diff --git a/test/collective/collective_alltoall_api.py b/test/collective/collective_alltoall_api.py index f81500b52df4c9..bf818cf9a9e406 100644 --- a/test/collective/collective_alltoall_api.py +++ b/test/collective/collective_alltoall_api.py @@ -95,8 +95,6 @@ def alltoall_new( paddle.split(out_tensor, nranks, 0) ) - return None - class TestCollectiveAllToAllAPI(TestCollectiveAPIRunnerBase): def __init__(self): diff --git a/test/collective/collective_reduce_api.py b/test/collective/collective_reduce_api.py index c71eff0bc6ecfc..88bfe7b7a8b3a4 100644 --- a/test/collective/collective_reduce_api.py +++ b/test/collective/collective_reduce_api.py @@ -60,7 +60,6 @@ def reduce_new(tensor, dst, reduce_type=str(dist.ReduceOp.SUM), group=None): 'reduce_type': int(reduce_type), }, ) - return None class TestCollectiveReduceAPI(TestCollectiveAPIRunnerBase): diff --git a/test/collective/collective_sendrecv_api.py b/test/collective/collective_sendrecv_api.py index b5fc01be7af15a..6e8301f17178b7 100644 --- a/test/collective/collective_sendrecv_api.py +++ b/test/collective/collective_sendrecv_api.py @@ -54,7 +54,6 @@ def send_new(tensor, dst, group=None, sync_op=True): 'dynamic_shape': True, }, ) - return None def recv_new(tensor, src, group=None, sync_op=True, dtype='float32'): @@ -88,7 +87,6 @@ def recv_new(tensor, src, group=None, sync_op=True, dtype='float32'): 'dtype': base.framework.convert_np_dtype_to_dtype_(dtype), }, ) - return None class TestCollectiveSendRecvAPI(TestCollectiveAPIRunnerBase): diff --git a/test/collective/fleet/dygraph_group_sharded_stage2.py b/test/collective/fleet/dygraph_group_sharded_stage2.py index 900ccb0468fd15..66795a0d2c9be7 100644 --- a/test/collective/fleet/dygraph_group_sharded_stage2.py +++ b/test/collective/fleet/dygraph_group_sharded_stage2.py @@ -241,7 +241,6 @@ def test_dp_stage2(): # check optimizer.minimize() error train_mlp(mlp7, sharding_stage=2, test_minimize=True) - return if __name__ == '__main__': diff --git a/test/collective/fleet/dygraph_group_sharded_stage2_comm_overlap.py b/test/collective/fleet/dygraph_group_sharded_stage2_comm_overlap.py index ed9149c3db3e74..debab7aca521b7 100644 --- a/test/collective/fleet/dygraph_group_sharded_stage2_comm_overlap.py +++ b/test/collective/fleet/dygraph_group_sharded_stage2_comm_overlap.py @@ -245,7 +245,6 @@ def test_dp_stage2(): # check optimizer.minimize() error train_mlp(mlp7, sharding_stage=2, test_minimize=True) - return if __name__ == '__main__': diff --git a/test/collective/fleet/dygraph_group_sharded_stage2_offload.py b/test/collective/fleet/dygraph_group_sharded_stage2_offload.py index e868b4ff3404da..aa36631caa9bf4 100644 --- a/test/collective/fleet/dygraph_group_sharded_stage2_offload.py +++ b/test/collective/fleet/dygraph_group_sharded_stage2_offload.py @@ -122,8 +122,6 @@ def test_sharding_stage2_offload(): except Exception as e: assert isinstance(e, AssertionError) - return - if __name__ == '__main__': test_sharding_stage2_offload() diff --git a/test/collective/fleet/dygraph_group_sharded_stage3_offload.py b/test/collective/fleet/dygraph_group_sharded_stage3_offload.py index fc7791fd09aaa6..22278aae90061d 100644 --- a/test/collective/fleet/dygraph_group_sharded_stage3_offload.py +++ b/test/collective/fleet/dygraph_group_sharded_stage3_offload.py @@ -250,7 +250,6 @@ def test_stage3_offload(): rtol=1e-6, atol=1e-8, ) - return if __name__ == '__main__': diff --git a/test/collective/fleet/hybrid_parallel_communicate_group.py b/test/collective/fleet/hybrid_parallel_communicate_group.py index 1b9febf04f8749..bb1b6b9382193c 100644 --- a/test/collective/fleet/hybrid_parallel_communicate_group.py +++ b/test/collective/fleet/hybrid_parallel_communicate_group.py @@ -100,8 +100,6 @@ def test_all(self): paddle.distributed.barrier(group=dp_gp) print("test barrier api ok") - return - if __name__ == "__main__": gpt = TestNewGroupAPI() diff --git a/test/collective/fleet/new_group.py b/test/collective/fleet/new_group.py index deeea066650190..a56d65217a40d4 100644 --- a/test/collective/fleet/new_group.py +++ b/test/collective/fleet/new_group.py @@ -76,8 +76,6 @@ def test_all(self): paddle.distributed.barrier(group=gp) print("test barrier api ok") - return - if __name__ == "__main__": gpt = TestNewGroupAPI() diff --git a/test/collective/fleet/test_fleet_meta_optimizer_base.py b/test/collective/fleet/test_fleet_meta_optimizer_base.py index 326f1bc64d48cb..8878fdc172e2f1 100755 --- a/test/collective/fleet/test_fleet_meta_optimizer_base.py +++ b/test/collective/fleet/test_fleet_meta_optimizer_base.py @@ -59,7 +59,6 @@ def net(main_prog, startup_prog): paddle.static.default_startup_program(), params_grads, ) - return None net(base.default_startup_program(), base.default_main_program()) diff --git a/test/dygraph_to_static/test_error.py b/test/dygraph_to_static/test_error.py index 22d2d9676fbd4c..762859d2d38f1c 100644 --- a/test/dygraph_to_static/test_error.py +++ b/test/dygraph_to_static/test_error.py @@ -28,7 +28,7 @@ def inner_func(): paddle.tensor.fill_constant(shape=[1, 2], value=9, dtype="int") - return + return # noqa: PLR1711 @paddle.jit.to_static @@ -97,7 +97,7 @@ def test_func(self): NOTE: The next line has a tab. And this test to check the IndentationError when spaces and tabs are mixed. A tab here. """ # fmt: skip - return + return # noqa: PLR1711 @paddle.jit.to_static diff --git a/test/dygraph_to_static/test_program_translator.py b/test/dygraph_to_static/test_program_translator.py index ac23492bc33b47..25cf316dd7e91c 100644 --- a/test/dygraph_to_static/test_program_translator.py +++ b/test/dygraph_to_static/test_program_translator.py @@ -81,12 +81,12 @@ def set_args_0(__args): def true_fn_0(): nonlocal x_v x_v = x_v - 1 - return + return # noqa: PLR1711 def false_fn_0(): nonlocal x_v x_v = x_v + 1 - return + return # noqa: PLR1711 _jst.IfElse( paddle.mean(x_v)[0] > 5, @@ -113,13 +113,13 @@ def true_fn_1(): ) __return_0 = _jst.create_bool_as_type(label is not None, True) __return_value_0 = loss - return + return # noqa: PLR1711 def false_fn_1(): nonlocal __return_0, __return_1, __return_value_0, loss __return_1 = _jst.create_bool_as_type(label is not None, True) __return_value_0 = x_v - return + return # noqa: PLR1711 _jst.IfElse( label is not None, @@ -152,12 +152,12 @@ def set_args_2(__args): def true_fn_2(): nonlocal x_v x_v = x_v - 1 - return + return # noqa: PLR1711 def false_fn_2(): nonlocal x_v x_v = x_v + 1 - return + return # noqa: PLR1711 _jst.IfElse( paddle.mean(x_v)[0] > 5, @@ -184,13 +184,13 @@ def true_fn_3(): ) __return_2 = _jst.create_bool_as_type(label is not None, True) __return_value_1 = loss - return + return # noqa: PLR1711 def false_fn_3(): nonlocal __return_2, __return_3, __return_value_1, loss __return_3 = _jst.create_bool_as_type(label is not None, True) __return_value_1 = x_v - return + return # noqa: PLR1711 _jst.IfElse( label is not None, diff --git a/test/dygraph_to_static/tsm_config_utils.py b/test/dygraph_to_static/tsm_config_utils.py index 1b74bf64cfc89e..5a19270eb8ede9 100644 --- a/test/dygraph_to_static/tsm_config_utils.py +++ b/test/dygraph_to_static/tsm_config_utils.py @@ -60,7 +60,6 @@ def create_attr_dict(yaml_config): create_attr_dict(yaml_config[key]) else: yaml_config[key] = value - return def merge_configs(cfg, sec, args_dict): diff --git a/test/legacy_test/test_lambv2_op.py b/test/legacy_test/test_lambv2_op.py index b55d6dceb13194..42dab23cc221fc 100644 --- a/test/legacy_test/test_lambv2_op.py +++ b/test/legacy_test/test_lambv2_op.py @@ -95,8 +95,6 @@ def _append_optimize_op(self, block, param_and_grad): paddle.assign(next_v, v) paddle.assign(next_param, param_and_grad[0]) - return None - class TestLambOpV2(unittest.TestCase): def test_lamb_op(self): diff --git a/test/legacy_test/test_static_pylayer.py b/test/legacy_test/test_static_pylayer.py index 27bbc6bfefb8f3..3a1634e92bf58b 100644 --- a/test/legacy_test/test_static_pylayer.py +++ b/test/legacy_test/test_static_pylayer.py @@ -174,7 +174,6 @@ def test_return_forward_none(self): def forward_fn(x): y = 3 * x - return None main_program = Program() start_program = Program() diff --git a/test/mkldnn/test_transpose_mkldnn_op.py b/test/mkldnn/test_transpose_mkldnn_op.py index 5286c561e0861b..66185f9daaf482 100644 --- a/test/mkldnn/test_transpose_mkldnn_op.py +++ b/test/mkldnn/test_transpose_mkldnn_op.py @@ -35,7 +35,6 @@ def setUp(self): def init_op_type(self): self.op_type = "transpose2" self.use_mkldnn = True - return def test_check_output(self): # TODO(wangzhongpu): support mkldnn op in dygraph mode diff --git a/test/prim/composite_ops/test_composite_batch_norm.py b/test/prim/composite_ops/test_composite_batch_norm.py index c74097b6e2313c..c90f9c4b9c91c1 100644 --- a/test/prim/composite_ops/test_composite_batch_norm.py +++ b/test/prim/composite_ops/test_composite_batch_norm.py @@ -45,31 +45,24 @@ def __init__(self) -> None: def set_dtype(self, dtype) -> None: self.dtype = dtype - return def set_shape(self, shape) -> None: self.shape = shape - return def set_training(self, training) -> None: self.training = training - return def set_momentum(self, momentum) -> None: self.momentum = momentum - return def set_epsilon(self, epsilon) -> None: self.epsilon = epsilon - return def set_data_format(self, data_format) -> None: self.data_format = data_format - return def set_use_global_stats(self, use_global_stats) -> None: self.use_global_stats = use_global_stats - return def get_rtol(self, flag): rtol = SUB_TOLERANCE[self.dtype][flag].get("rtol") diff --git a/test/prim/composite_ops/test_composite_batch_norm_grad.py b/test/prim/composite_ops/test_composite_batch_norm_grad.py index f23fe76456994f..6a45d193053e0b 100644 --- a/test/prim/composite_ops/test_composite_batch_norm_grad.py +++ b/test/prim/composite_ops/test_composite_batch_norm_grad.py @@ -46,31 +46,24 @@ def __init__(self) -> None: def set_dtype(self, dtype) -> None: self.dtype = dtype - return def set_shape(self, shape) -> None: self.shape = shape - return def set_training(self, training) -> None: self.training = training - return def set_momentum(self, momentum) -> None: self.momentum = momentum - return def set_epsilon(self, epsilon) -> None: self.epsilon = epsilon - return def set_data_format(self, data_format) -> None: self.data_format = data_format - return def set_use_global_stats(self, use_global_stats) -> None: self.use_global_stats = use_global_stats - return def get_rtol(self, flag): rtol = SUB_TOLERANCE[self.dtype][flag].get("rtol") diff --git a/test/prim/composite_ops/test_composite_gelu.py b/test/prim/composite_ops/test_composite_gelu.py index 89c721be8a5046..e36bb7fcc450e2 100644 --- a/test/prim/composite_ops/test_composite_gelu.py +++ b/test/prim/composite_ops/test_composite_gelu.py @@ -38,15 +38,12 @@ def __init__(self) -> None: def set_dtype(self, dtype) -> None: self.dtype = dtype - return def set_shape(self, shape) -> None: self.shape = shape - return def set_approximate(self, approximate) -> None: self.approximate = approximate - return def get_rtol(self, flag): rtol = TOLERANCE[self.dtype][flag].get("rtol") diff --git a/test/prim/composite_ops/test_composite_gelu_grad.py b/test/prim/composite_ops/test_composite_gelu_grad.py index c87e985ebe8ff4..47d6c28941eba2 100644 --- a/test/prim/composite_ops/test_composite_gelu_grad.py +++ b/test/prim/composite_ops/test_composite_gelu_grad.py @@ -38,15 +38,12 @@ def __init__(self) -> None: def set_dtype(self, dtype) -> None: self.dtype = dtype - return def set_shape(self, shape) -> None: self.shape = shape - return def set_approximate(self, approximate) -> None: self.approximate = approximate - return def get_rtol(self, flag): rtol = TOLERANCE[self.dtype][flag].get("rtol") diff --git a/test/prim/composite_ops/test_composite_layer_norm.py b/test/prim/composite_ops/test_composite_layer_norm.py index 1f3fc2ccf31cdf..88be2af37551e8 100644 --- a/test/prim/composite_ops/test_composite_layer_norm.py +++ b/test/prim/composite_ops/test_composite_layer_norm.py @@ -107,14 +107,12 @@ def __init__(self) -> None: def set_dtype(self, dtype) -> None: self.dtype = dtype - return def set_shape(self, n_shape, shape1=[], shape2=[], shape3=[]) -> None: self.n_shape = n_shape self.shape1 = shape1 self.shape2 = shape2 self.shape3 = shape3 - return def get_rtol(self, flag): rtol = SUB_TOLERANCE[self.dtype][flag].get("rtol") diff --git a/test/prim/composite_ops/test_composite_layer_norm_grad.py b/test/prim/composite_ops/test_composite_layer_norm_grad.py index 06940b82fc7044..2c76aab6feca22 100644 --- a/test/prim/composite_ops/test_composite_layer_norm_grad.py +++ b/test/prim/composite_ops/test_composite_layer_norm_grad.py @@ -141,14 +141,12 @@ def __init__(self) -> None: def set_dtype(self, dtype) -> None: self.dtype = dtype - return def set_shape(self, n_shape, shape1, shape2, shape3) -> None: self.n_shape = n_shape self.shape1 = shape1 self.shape2 = shape2 self.shape3 = shape3 - return def get_rtol(self, flag): rtol = SUB_TOLERANCE[self.dtype][flag].get("rtol") diff --git a/test/prim/composite_ops/test_composite_mean.py b/test/prim/composite_ops/test_composite_mean.py index 01d8feb72ba90a..5369bdb250e469 100644 --- a/test/prim/composite_ops/test_composite_mean.py +++ b/test/prim/composite_ops/test_composite_mean.py @@ -37,19 +37,15 @@ def __init__(self) -> None: def set_dtype(self, dtype) -> None: self.dtype = dtype - return def set_keepdim(self, keepdim) -> None: self.keepdim = keepdim - return def set_axis(self, axis) -> None: self.axis = axis - return def set_shape(self, shape) -> None: self.shape = shape - return def get_rtol(self, flag): rtol = TOLERANCE[self.dtype][flag].get("rtol") diff --git a/test/prim/composite_ops/test_composite_mean_grad.py b/test/prim/composite_ops/test_composite_mean_grad.py index ba952ff3258bda..00c8eb12f147d9 100644 --- a/test/prim/composite_ops/test_composite_mean_grad.py +++ b/test/prim/composite_ops/test_composite_mean_grad.py @@ -37,19 +37,15 @@ def __init__(self) -> None: def set_dtype(self, dtype) -> None: self.dtype = dtype - return def set_keepdim(self, keepdim) -> None: self.keepdim = keepdim - return def set_axis(self, axis) -> None: self.axis = axis - return def set_shape(self, shape) -> None: self.shape = shape - return def get_rtol(self, flag): rtol = TOLERANCE[self.dtype][flag].get("rtol") diff --git a/test/prim/composite_ops/test_composite_relu_custom_vjp.py b/test/prim/composite_ops/test_composite_relu_custom_vjp.py index af99b78d36d1ef..cf63e232853d8f 100644 --- a/test/prim/composite_ops/test_composite_relu_custom_vjp.py +++ b/test/prim/composite_ops/test_composite_relu_custom_vjp.py @@ -34,11 +34,9 @@ def __init__(self) -> None: def set_dtype(self, dtype) -> None: self.dtype = dtype - return def set_shape(self, shape) -> None: self.shape = shape - return def get_rtol(self, flag): rtol = TOLERANCE[self.dtype][flag].get("rtol") diff --git a/test/prim/composite_ops/test_composite_softmax.py b/test/prim/composite_ops/test_composite_softmax.py index ccd918f045b57d..7f66453fe37e50 100644 --- a/test/prim/composite_ops/test_composite_softmax.py +++ b/test/prim/composite_ops/test_composite_softmax.py @@ -36,15 +36,12 @@ def __init__(self) -> None: def set_dtype(self, dtype) -> None: self.dtype = dtype - return def set_axis(self, axis) -> None: self.axis = axis - return def set_shape(self, shape) -> None: self.shape = shape - return def get_rtol(self, flag): rtol = TOLERANCE[self.dtype][flag].get("rtol") diff --git a/test/prim/composite_ops/test_composite_softmax_custom_vjp.py b/test/prim/composite_ops/test_composite_softmax_custom_vjp.py index d89574f2d521fd..8cc025838fe776 100644 --- a/test/prim/composite_ops/test_composite_softmax_custom_vjp.py +++ b/test/prim/composite_ops/test_composite_softmax_custom_vjp.py @@ -35,15 +35,12 @@ def __init__(self) -> None: def set_dtype(self, dtype) -> None: self.dtype = dtype - return def set_axis(self, axis) -> None: self.axis = axis - return def set_shape(self, shape) -> None: self.shape = shape - return def get_rtol(self, flag): rtol = TOLERANCE[self.dtype][flag].get("rtol") diff --git a/test/prim/composite_ops/test_composite_softmax_grad.py b/test/prim/composite_ops/test_composite_softmax_grad.py index bf228b569a9c3f..f9683886bbbcee 100644 --- a/test/prim/composite_ops/test_composite_softmax_grad.py +++ b/test/prim/composite_ops/test_composite_softmax_grad.py @@ -36,15 +36,12 @@ def __init__(self) -> None: def set_dtype(self, dtype) -> None: self.dtype = dtype - return def set_axis(self, axis) -> None: self.axis = axis - return def set_shape(self, shape) -> None: self.shape = shape - return def get_rtol(self, flag): rtol = TOLERANCE[self.dtype][flag].get("rtol") diff --git a/test/prim/prim/flags/test_prim_flags.py b/test/prim/prim/flags/test_prim_flags.py index 610d8acdd63154..c1164a5e626e47 100644 --- a/test/prim/prim/flags/test_prim_flags.py +++ b/test/prim/prim/flags/test_prim_flags.py @@ -101,7 +101,6 @@ def not_in_blacklist(self): _ = exe.run(main_program, feed={'x': inputs}, fetch_list=[y]) paddle.disable_static() core._set_prim_forward_enabled(False) - return def in_blacklist(self): inputs = np.random.random([2, 3, 4]).astype("float32") @@ -131,7 +130,6 @@ def in_blacklist(self): _ = exe.run(main_program, feed={'x': inputs}, fetch_list=[y]) paddle.disable_static() core._set_prim_forward_enabled(False) - return def test_prim_forward_blacklist(self): self.not_in_blacklist() @@ -161,7 +159,6 @@ def train(self): loss = paddle.mean(out) loss.backward() self.check_prim(net) - return def check_prim(self, net): block = net.forward.program_cache.last()[-1][-1].train_program.block diff --git a/test/prim/prim/flags/test_prim_flags_case.py b/test/prim/prim/flags/test_prim_flags_case.py index d244aca1faca28..126c15de81fe2f 100644 --- a/test/prim/prim/flags/test_prim_flags_case.py +++ b/test/prim/prim/flags/test_prim_flags_case.py @@ -64,8 +64,6 @@ def train(self, use_cinn): self.check_prim(net) - return - def check_prim(self, net): ops = [ op.type diff --git a/test/prim/prim/vjp/eager/test_comp_eager_batch_norm_grad.py b/test/prim/prim/vjp/eager/test_comp_eager_batch_norm_grad.py index 720653b3d0240b..c4c773cfcbafde 100644 --- a/test/prim/prim/vjp/eager/test_comp_eager_batch_norm_grad.py +++ b/test/prim/prim/vjp/eager/test_comp_eager_batch_norm_grad.py @@ -44,31 +44,24 @@ def __init__(self) -> None: def set_dtype(self, dtype) -> None: self.dtype = dtype - return def set_shape(self, shape) -> None: self.shape = shape - return def set_training(self, training) -> None: self.training = training - return def set_momentum(self, momentum) -> None: self.momentum = momentum - return def set_epsilon(self, epsilon) -> None: self.epsilon = epsilon - return def set_data_format(self, data_format) -> None: self.data_format = data_format - return def set_use_global_stats(self, use_global_stats) -> None: self.use_global_stats = use_global_stats - return attrs = Attr() diff --git a/test/prim/prim/vjp/static/test_comp_batch_norm_grad.py b/test/prim/prim/vjp/static/test_comp_batch_norm_grad.py index b8f25b51312031..f6e2b3524b110c 100644 --- a/test/prim/prim/vjp/static/test_comp_batch_norm_grad.py +++ b/test/prim/prim/vjp/static/test_comp_batch_norm_grad.py @@ -44,31 +44,24 @@ def __init__(self) -> None: def set_dtype(self, dtype) -> None: self.dtype = dtype - return def set_shape(self, shape) -> None: self.shape = shape - return def set_training(self, training) -> None: self.training = training - return def set_momentum(self, momentum) -> None: self.momentum = momentum - return def set_epsilon(self, epsilon) -> None: self.epsilon = epsilon - return def set_data_format(self, data_format) -> None: self.data_format = data_format - return def set_use_global_stats(self, use_global_stats) -> None: self.use_global_stats = use_global_stats - return attrs = Attr()