[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):
inps = inps.strip().strip("'")
global_vals = {
**{
"T": deserialize_tensor,
"ST": deserialize_sparse_tensor,
"th": torch,
"inf": math.inf,
"torch": torch,
},
**dtype_abbrs_parsing,
}
# f strings introduce quotations we dont want

View File

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

View File

@ -59,7 +59,7 @@ class _PartialWrapper:
# skip if arg_name in keywords so its possible to overwrite
for arg_name in self.callable_args:
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)
def __repr__(self):

View File

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