From a688a237d7593e1f21684dc24eb76bb37999707b Mon Sep 17 00:00:00 2001 From: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com> Date: Thu, 23 Feb 2023 22:24:23 +0100 Subject: [PATCH] Add black to pre-commit (#3192) --- .pre-commit-config.yaml | 11 +++++++++++ scripts/add_plugin.py | 2 +- scripts/add_rule.py | 2 +- scripts/generate_known_standard_library.py | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 719bfa811c..23d27b1563 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,5 +46,16 @@ repos: pass_filenames: false exclude: target + # Black + - repo: https://github.com/psf/black + rev: 23.1.0 + hooks: + - id: black + exclude: | + (?x)^( + crates/ruff/resources/.*| + crates/ruff_python_formatter/resources/.* + )$ + ci: skip: [cargo-fmt, clippy, dev-generate-all] diff --git a/scripts/add_plugin.py b/scripts/add_plugin.py index e30843f87d..64e57307c9 100755 --- a/scripts/add_plugin.py +++ b/scripts/add_plugin.py @@ -95,7 +95,7 @@ mod tests { with (ROOT_DIR / "crates/ruff/src/codes.rs").open("r") as fp: while (line := next(fp)).strip() != "// ruff": text += line - text += " "*8 + f"// {plugin}\n" + text += " " * 8 + f"// {plugin}\n" text += line text += fp.read() diff --git a/scripts/add_rule.py b/scripts/add_rule.py index b3cf699979..e7cdddd563 100755 --- a/scripts/add_rule.py +++ b/scripts/add_rule.py @@ -140,7 +140,7 @@ pub fn {rule_name_snake}(checker: &mut Checker) {{}} text += line text += line linter_variant = pascal_case(linter) - text += " "*8 + f'({linter_variant}, "{code}") => Rule::{name},\n' + text += " " * 8 + f'({linter_variant}, "{code}") => Rule::{name},\n' text += fp.read() with (ROOT_DIR / "crates/ruff/src/codes.rs").open("w") as fp: diff --git a/scripts/generate_known_standard_library.py b/scripts/generate_known_standard_library.py index 7133c71a84..88039d7c90 100644 --- a/scripts/generate_known_standard_library.py +++ b/scripts/generate_known_standard_library.py @@ -42,7 +42,7 @@ pub static KNOWN_STANDARD_LIBRARY: Lazy