Raise percent-format upgrade rule (UP031) for hanging modulos (#3953)

This commit is contained in:
Charlie Marsh 2023-04-12 23:59:20 -04:00 committed by GitHub
parent 9067ae47d1
commit e160a52bfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 142 additions and 43 deletions

View file

@ -103,23 +103,22 @@ def main(*, name: str, prefix: str, code: str, linter: str) -> None:
# Add the relevant rule function.
with (rules_dir / f"{rule_name_snake}.rs").open("w") as fp:
fp.write(
"""\
f"""\
use ruff_diagnostics::Violation;
use ruff_macros::{derive_message_formats, violation};
use ruff_macros::{{derive_message_formats, violation}};
use crate::checkers::ast::Checker;
#[violation]
pub struct %s;
impl Violation for %s {
pub struct {name};
impl Violation for {name} {{
#[derive_message_formats]
fn message(&self) -> String {
fn message(&self) -> String {{
todo!("implement message");
format!("TODO: write message")
}
}
"""
% (name, name),
}}
}}
""",
)
fp.write(
f"""