ruff: Fix FURB122 Use of f.write in a for loop.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2025-06-17 14:07:36 -07:00
committed by Tim Abbott
parent e8fdae8f7b
commit f990a1400f
3 changed files with 3 additions and 6 deletions

View File

@@ -66,8 +66,7 @@ if __name__ == "__main__":
else:
keys = get_mentor_keys(args.username)
with open(authorized_keys, "a") as f:
for key in keys:
f.write(append_key.format(username=args.username, key=key))
f.writelines(append_key.format(username=args.username, key=key) for key in keys)
print(f"Successfully added {args.username}'s SSH key!")
print("Can you let your mentor know that they can connect to this machine with:\n")

View File

@@ -571,8 +571,7 @@ def write_instrumentation_reports(full_suite: bool, include_webhooks: bool) -> N
var_dir = "var" # TODO make sure path is robust here
fn = os.path.join(var_dir, "url_coverage.txt")
with open(fn, "wb") as f:
for call in calls:
f.write(orjson.dumps(call, option=orjson.OPT_APPEND_NEWLINE))
f.writelines(orjson.dumps(call, option=orjson.OPT_APPEND_NEWLINE) for call in calls)
if full_suite:
print(f"INFO: URL coverage report is in {fn}")

View File

@@ -302,8 +302,7 @@ class Runner(DiscoverRunner):
os.makedirs(os.path.dirname(filepath), exist_ok=True)
with open(filepath, "w") as f:
if self.parallel > 1:
for index in range(self.parallel):
f.write(get_database_id(index + 1) + "\n")
f.writelines(get_database_id(index + 1) + "\n" for index in range(self.parallel))
else:
f.write(get_database_id() + "\n")