[BE] Enable ruff's UP rules and autoformat tools and scripts (#105428)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/105428
Approved by: https://github.com/albanD, https://github.com/soulitzer, https://github.com/malfet
This commit is contained in:
Justin Chu
2023-07-18 21:12:48 +00:00
committed by PyTorch MergeBot
parent 5666d20bb8
commit 14d87bb5ff
48 changed files with 125 additions and 146 deletions

View File

@ -31,7 +31,7 @@ def generate_example_rst(example_case: ExportCase):
if isinstance(model, torch.nn.Module)
else inspect.getfile(model)
)
with open(source_file, "r") as file:
with open(source_file) as file:
source_code = file.read()
source_code = re.sub(r"from torch\._export\.db\.case import .*\n", "", source_code)
source_code = re.sub(r"@export_case\((.|\n)*?\)\n", "", source_code)
@ -114,7 +114,7 @@ def generate_index_rst(example_cases, tag_to_modules, support_level_to_modules):
tag_names = "\n ".join(t for t in tag_to_modules.keys())
with open(os.path.join(PWD, "blurb.txt"), "r") as file:
with open(os.path.join(PWD, "blurb.txt")) as file:
blurb = file.read()
# Generate contents of the .rst file