mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:39:12 +00:00
Replace row/column based Location
with byte-offsets. (#3931)
This commit is contained in:
parent
ee91598835
commit
cab65b25da
418 changed files with 6203 additions and 7040 deletions
|
@ -11,6 +11,7 @@ Example usage:
|
|||
"""
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
from _utils import ROOT_DIR, dir_name, get_indent, pascal_case, snake_case
|
||||
|
||||
|
@ -79,17 +80,10 @@ def main(*, name: str, prefix: str, code: str, linter: str) -> None:
|
|||
new_mod = f"mod {rule_name_snake};"
|
||||
|
||||
if len(parts) == 2:
|
||||
pub_use_contents = parts[0].split(";\n")
|
||||
pub_use_contents.append(new_pub_use)
|
||||
pub_use_contents.sort()
|
||||
|
||||
mod_contents = parts[1].splitlines()
|
||||
mod_contents.append(new_mod)
|
||||
mod_contents.sort()
|
||||
|
||||
new_contents = ";\n".join(pub_use_contents)
|
||||
new_contents = parts[0]
|
||||
new_contents += "\n" + new_pub_use + ";"
|
||||
new_contents += "\n\n"
|
||||
new_contents += "\n".join(mod_contents)
|
||||
new_contents += parts[1] + new_mod
|
||||
new_contents += "\n"
|
||||
|
||||
rules_mod.write_text(new_contents)
|
||||
|
@ -201,6 +195,12 @@ pub fn {rule_name_snake}(checker: &mut Checker) {{}}
|
|||
with (ROOT_DIR / "crates/ruff/src/codes.rs").open("w") as fp:
|
||||
fp.write(text)
|
||||
|
||||
_rustfmt(rules_mod)
|
||||
|
||||
|
||||
def _rustfmt(path: str) -> None:
|
||||
subprocess.run(["rustfmt", path])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue