From 7913940a41832c9d20ded89a6a5b907979bd3a60 Mon Sep 17 00:00:00 2001 From: yuchen202 <103028470+yuchen202@users.noreply.github.com> Date: Mon, 16 Oct 2023 14:42:28 +0800 Subject: [PATCH] [CodeStyle][task 21] enable ruff C405 rule in `python/paddle/base` (#58056) * 1012 * Update python/paddle/base/multiprocess_utils.py Co-authored-by: gouzil <66515297+gouzil@users.noreply.github.com> * clean a duplicate `if` --------- Co-authored-by: Nyakku Shigure Co-authored-by: gouzil <66515297+gouzil@users.noreply.github.com> --- pyproject.toml | 1 - python/paddle/base/backward.py | 2 +- python/paddle/base/dygraph/base.py | 2 -- python/paddle/base/multiprocess_utils.py | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f50f5a363b2c0b..393d46b6f8a5f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -107,7 +107,6 @@ ignore = [ # Temporarily ignored "python/paddle/base/**" = [ "UP030", - "C405", "B019", # Confirmation required "C416", "F821", diff --git a/python/paddle/base/backward.py b/python/paddle/base/backward.py index 3e057dcb12cf7e..876db0abc3aa70 100755 --- a/python/paddle/base/backward.py +++ b/python/paddle/base/backward.py @@ -2067,7 +2067,7 @@ def append_backward( # not support double grad in control flow sub-block now. if not is_in_control_flow: if program._appending_grad_times > 1: - input_grad_names_set = set([_append_grad_suffix_(loss.name)]) + input_grad_names_set = {_append_grad_suffix_(loss.name)} # TODO: support _append_backward_ops_with_checkpoints_ in # sub-block (control flow) diff --git a/python/paddle/base/dygraph/base.py b/python/paddle/base/dygraph/base.py index 43f8700656e351..5fad89935d4c7e 100644 --- a/python/paddle/base/dygraph/base.py +++ b/python/paddle/base/dygraph/base.py @@ -800,8 +800,6 @@ def check_in_out(in_out_list, name): no_grad_vars = [] elif isinstance(no_grad_vars, core.eager.Tensor): no_grad_vars = [no_grad_vars] - elif isinstance(no_grad_vars, core.eager.Tensor): - no_grad_vars = [no_grad_vars] elif isinstance(no_grad_vars, (list, tuple, set)): no_grad_vars = list(no_grad_vars) for var in no_grad_vars: diff --git a/python/paddle/base/multiprocess_utils.py b/python/paddle/base/multiprocess_utils.py index 8d18db0bb3ea85..9b70cacd1c2cd8 100644 --- a/python/paddle/base/multiprocess_utils.py +++ b/python/paddle/base/multiprocess_utils.py @@ -73,7 +73,6 @@ def _func_register(function): if not callable(function): raise TypeError("%s is not callable object." % (function)) # check function object whether hash-able - set([function]) if function not in cls._registered_func_set: atexit.register(_func_exectuor) cls._registered_func_set.add(function)