mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:48:32 +00:00
Raise percent-format upgrade rule (UP031
) for hanging modulos (#3953)
This commit is contained in:
parent
9067ae47d1
commit
e160a52bfd
6 changed files with 142 additions and 43 deletions
|
@ -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"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue