[refurb] Implement write-whole-file (FURB103) (#10802)

## Summary

Implement `write-whole-file` (`FURB103`), part of #1348. This is largely
a copy and paste of `read-whole-file` #7682.

## Test Plan

Text fixture added.

---------

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
This commit is contained in:
Auguste Lalande 2024-04-11 04:51:45 -04:00 committed by GitHub
parent ac14d187c6
commit ffea1bb0a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 640 additions and 189 deletions

View file

@ -27,9 +27,7 @@ def main(*, name: str, prefix: str, code: str, linter: str) -> None:
/ "crates/ruff_linter/resources/test/fixtures"
/ dir_name(linter)
/ f"{filestem}.py"
).open(
"a",
):
).open("a"):
pass
plugin_module = ROOT_DIR / "crates/ruff_linter/src/rules" / dir_name(linter)
@ -141,7 +139,7 @@ pub(crate) fn {rule_name_snake}(checker: &mut Checker) {{}}
variant = pascal_case(linter)
rule = f"""rules::{linter.split(" ")[0]}::rules::{name}"""
lines.append(
" " * 8 + f"""({variant}, "{code}") => (RuleGroup::Stable, {rule}),\n""",
" " * 8 + f"""({variant}, "{code}") => (RuleGroup::Preview, {rule}),\n""",
)
lines.sort()
text += "".join(lines)