[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

@ -173,7 +173,7 @@ def write_test_to_test_class(
assert not ('cpp_options_args' in test_params_dict and 'cpp_function_call' in test_params_dict), (
"Only one of `cpp_options_args` and `cpp_function_call` entries "
"should be present in test params dict:\n{}").format(pprint.pformat(test_params_dict))
f"should be present in test params dict:\n{pprint.pformat(test_params_dict)}")
functional_name = compute_functional_name(test_params_dict)

View File

@ -209,11 +209,11 @@ def process_test_params_for_module(test_params_dict, device, test_instance_class
if 'constructor_args' in test_params_dict:
assert 'cpp_constructor_args' in test_params_dict, (
"If `constructor_args` is present in test params dict, to enable C++ API parity test, "
"`cpp_constructor_args` must be present in:\n{}"
f"`cpp_constructor_args` must be present in:\n{pprint.pformat(test_params_dict)}"
"If you are interested in adding the C++ API parity test, please see:\n"
"NOTE [How to check NN module / functional API parity between Python and C++ frontends]. \n"
"If not, please add `test_cpp_api_parity=False` to the test params dict and file an issue about this."
).format(pprint.pformat(test_params_dict))
)
return TorchNNModuleTestParams(
module_name=module_name,
@ -233,16 +233,16 @@ def write_test_to_test_class(
module_name = compute_module_name(test_params_dict)
assert hasattr(torch.nn, module_name), (
"`torch.nn` doesn't have module `{}`. "
f"`torch.nn` doesn't have module `{module_name}`. "
"If you are adding a new test, please set `fullname` using format `ModuleName_desc` "
"or set `module_name` using format `ModuleName` in the module test dict:\n{}"
).format(module_name, pprint.pformat(test_params_dict))
f"or set `module_name` using format `ModuleName` in the module test dict:\n{pprint.pformat(test_params_dict)}"
)
module_full_name = 'torch::nn::' + module_name
assert module_full_name in parity_table['torch::nn'], (
"Please add `{}` entry to `torch::nn` section of `test/cpp_api_parity/parity-tracker.md`. "
"(Discovered while processing\n{}.)").format(module_full_name, pprint.pformat(test_params_dict))
f"Please add `{module_full_name}` entry to `torch::nn` section of `test/cpp_api_parity/parity-tracker.md`. "
f"(Discovered while processing\n{pprint.pformat(test_params_dict)}.)")
for device in devices:
test_params = process_test_params_for_module(