Skip to content

Commit

Permalink
[CodeStyle][task 22] enable Ruff C417 rule in python/paddle/base (P…
Browse files Browse the repository at this point in the history
…addlePaddle#57634)

* fix Ruff_C417

* remove pyproject.toml/C417
  • Loading branch information
zade23 authored Sep 25, 2023
1 parent 1bb65da commit 2e34396
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 18 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ ignore = [
"C408",
"UP030",
"C405",
"C417",
"B004",
"B009",
"B016",
Expand Down
14 changes: 2 additions & 12 deletions python/paddle/base/backward.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,22 +345,12 @@ def _create_op_desc_(op_type, inputs, outputs, attrs):
for para, args in inputs.items():
op_desc.set_input(
para,
list(
map(
lambda arg: arg.decode() if isinstance(arg, bytes) else arg,
args,
)
),
[arg.decode() if isinstance(arg, bytes) else arg for arg in args],
)
for para, args in outputs.items():
op_desc.set_output(
para,
list(
map(
lambda arg: arg.decode() if isinstance(arg, bytes) else arg,
args,
)
),
[arg.decode() if isinstance(arg, bytes) else arg for arg in args],
)
op_role_attr_name = core.op_proto_and_checker_maker.kOpRoleAttrName()
op_device_attr_name = core.op_proto_and_checker_maker.kOpDeviceAttrName()
Expand Down
4 changes: 1 addition & 3 deletions python/paddle/static/nn/control_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1422,9 +1422,7 @@ def _select_input_infer_shape(first_shape, second_shape):
f"the input shapes of select_input should have the same rank, but get {first_shape}, {second_shape}"
)
return second_shape
out_shape = list(
map(lambda a, b: a if a == b else -1, first_shape, second_shape)
)
out_shape = [a if a == b else -1 for a, b in zip(first_shape, second_shape)]
return out_shape


Expand Down
2 changes: 1 addition & 1 deletion test/legacy_test/test_lstm_cudnn_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def update_state(mask, new, old):
if not isinstance(old, (tuple, list)):
return np.where(mask, new, old)
else:
return tuple(map(lambda x, y: np.where(mask, x, y), new, old))
return tuple(np.where(mask, x, y) for x, y in zip(new, old))


def rnn(
Expand Down
2 changes: 1 addition & 1 deletion test/rnn/rnn_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def update_state(mask, new, old):
if not isinstance(old, (tuple, list)):
return np.where(mask, new, old)
else:
return tuple(map(lambda x, y: np.where(mask, x, y), new, old))
return tuple(np.where(mask, x, y) for x, y in zip(new, old))


def rnn(
Expand Down

0 comments on commit 2e34396

Please sign in to comment.