[BE]: Update ruff to 0.285 (#107519)

This updates ruff to 0.285 which is faster, better, and have fixes a bunch of false negatives with regards to fstrings.

I also enabled RUF017 which looks for accidental quadratic list summation. Luckily, seems like there are no instances of it in our codebase, so enabling it so that it stays like that. :)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/107519
Approved by: https://github.com/ezyang
This commit is contained in:
Aaron Gokaslan
2023-08-20 01:36:14 +00:00
committed by PyTorch MergeBot
parent 02c2b750c5
commit 88ab3e4322
86 changed files with 319 additions and 403 deletions

View File

@ -257,7 +257,7 @@ class OrderedModuleDict(OrderedDictWrapper):
else:
raise RuntimeError(
"Cannot re-assign modules in a ScriptModule with non-scripted "
"module, tried to replace existing module '{}': {}".format(k, v)
f"module, tried to replace existing module '{k}': {v}"
)
def __getitem__(self, k):
@ -1402,7 +1402,7 @@ def _check_overload_defaults(impl_defaults, overload_defaults, loc):
loc,
"Default parameters on overloads do not affect the runtime so they "
"must equal to the default parameter on the implementation function. Found on "
"parameter {name}".format(name=name),
f"parameter {name}",
)
@ -1461,9 +1461,9 @@ def _check_directly_compile_overloaded(obj):
qual_name = _qualified_name(obj)
if _jit_internal._get_fn_overloads(qual_name) or _try_get_jit_cached_overloads(obj):
raise RuntimeError(
"Function {} cannot be directly compiled because it"
f"Function {qual_name} cannot be directly compiled because it"
" is overloaded. It must be used in a context of a function"
" where its inputs can determine which overload to call.".format(qual_name)
" where its inputs can determine which overload to call."
)