[BE]: Enable ruff rule PIE800 - unnecessary nested dict expansion (#113880)

Adds an additional list which removes unnecessary dict literal unpacking, also applies the fixes.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/113880
Approved by: https://github.com/albanD
This commit is contained in:
Aaron Gokaslan
2023-11-16 22:34:34 +00:00
committed by PyTorch MergeBot
parent bdf0b196db
commit d9f2cf9974
4 changed files with 8 additions and 9 deletions

View File

@ -222,13 +222,11 @@ def map_to_dtype(e, dtype):
def deserialize_args(inps): def deserialize_args(inps):
inps = inps.strip().strip("'") inps = inps.strip().strip("'")
global_vals = { global_vals = {
**{ "T": deserialize_tensor,
"T": deserialize_tensor, "ST": deserialize_sparse_tensor,
"ST": deserialize_sparse_tensor, "th": torch,
"th": torch, "inf": math.inf,
"inf": math.inf, "torch": torch,
"torch": torch,
},
**dtype_abbrs_parsing, **dtype_abbrs_parsing,
} }
# f strings introduce quotations we dont want # f strings introduce quotations we dont want

View File

@ -78,6 +78,7 @@ select = [
"PERF", "PERF",
"PGH004", "PGH004",
"PIE794", "PIE794",
"PIE800",
"PIE807", "PIE807",
"PIE810", "PIE810",
"PLE", "PLE",

View File

@ -59,7 +59,7 @@ class _PartialWrapper:
# skip if arg_name in keywords so its possible to overwrite # skip if arg_name in keywords so its possible to overwrite
for arg_name in self.callable_args: for arg_name in self.callable_args:
if arg_name not in keywords: if arg_name not in keywords:
keywords = {**keywords, **{arg_name: self.callable_args[arg_name]()}} keywords = {**keywords, arg_name: self.callable_args[arg_name]()}
return self.p(*args, **keywords) return self.p(*args, **keywords)
def __repr__(self): def __repr__(self):

View File

@ -433,7 +433,7 @@ def enable_wrap(
instances inside the context instances inside the context
""" """
kwargs = { kwargs = {
**{"wrapper_cls": wrapper_cls}, "wrapper_cls": wrapper_cls,
**wrapper_kwargs, **wrapper_kwargs,
} }
with _ConfigAutoWrap(**kwargs): with _ConfigAutoWrap(**kwargs):