[BE] Enable flake8-comprehension rule C417 (#97880)

Enables flake8-comprehension rule C417. Ruff autogenerated these fixes to the codebase.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/97880
Approved by: https://github.com/ezyang, https://github.com/kit1980, https://github.com/albanD
This commit is contained in:
Aaron Gokaslan
2023-03-30 14:34:24 +00:00
committed by PyTorch MergeBot
parent 1d08b5b103
commit 47dca20d80
36 changed files with 108 additions and 124 deletions

View File

@ -159,9 +159,9 @@ _SKIP_PYTHON_BINDINGS = [
"_nested_view_from_buffer_copy_out",
]
SKIP_PYTHON_BINDINGS = list(
map(lambda pattern: re.compile(rf"^{pattern}$"), _SKIP_PYTHON_BINDINGS)
)
SKIP_PYTHON_BINDINGS = [
re.compile(rf"^{pattern}$") for pattern in _SKIP_PYTHON_BINDINGS
]
# These function signatures are not exposed to Python. Note that this signature
# list does not support regex.
@ -864,7 +864,7 @@ def method_impl(
name=name,
pycname=pycname,
method_header=method_header,
max_args=max(map(lambda o: o.signature.arguments_count(), overloads)),
max_args=max((o.signature.arguments_count() for o in overloads)),
signatures=signatures,
traceable=traceable,
check_has_torch_function=gen_has_torch_function_check(
@ -1216,7 +1216,7 @@ def sort_overloads(
del larger_than[j]
sorted_ids.append(j)
return list(map(lambda x: grouped_overloads[x], sorted_ids))
return [grouped_overloads[x] for x in sorted_ids]
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
@ -1250,9 +1250,9 @@ def emit_single_dispatch(
# dispatch lambda signature
name = cpp.name(f.func)
lambda_formals = ", ".join(
map(
lambda a: f"{a.type_str} {a.name}",
dispatch_lambda_args(ps, f, symint=symint),
(
f"{a.type_str} {a.name}"
for a in dispatch_lambda_args(ps, f, symint=symint)
)
)
lambda_return = dispatch_lambda_return_str(f)