Replace row/column based Location with byte-offsets. (#3931)

This commit is contained in:
Micha Reiser 2023-04-26 20:11:02 +02:00 committed by GitHub
parent ee91598835
commit cab65b25da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
418 changed files with 6203 additions and 7040 deletions

View file

@ -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(