From 3476e2f35948c9ce04a1fbe7e5c3b9f923bb0fa2 Mon Sep 17 00:00:00 2001 From: Evan Kohilas Date: Wed, 22 May 2024 13:39:50 +1000 Subject: [PATCH] fixes invalid rule from hyphen (#11484) ## Summary When using `add_rule.py`, it produces the following line in `codes.rs` ``` (Flake8Async, "102") => (RuleGroup::Stable, rules::flake8-async::rules::BlockingOsCallInAsyncFunction), ``` Causing a syntax error. This PR resolves that issue so that the script can be used again. ## Test Plan Tested manually in new rule creation --- scripts/add_rule.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/add_rule.py b/scripts/add_rule.py index d324e8001b4e5..fbb2f66b18d0e 100755 --- a/scripts/add_rule.py +++ b/scripts/add_rule.py @@ -137,7 +137,8 @@ def main(*, name: str, prefix: str, code: str, linter: str) -> None: lines.append(line) variant = pascal_case(linter) - rule = f"""rules::{linter.split(" ")[0]}::rules::{name}""" + linter_name = linter.split(" ")[0].replace("-", "_") + rule = f"""rules::{linter_name}::rules::{name}""" lines.append( " " * 8 + f"""({variant}, "{code}") => (RuleGroup::Preview, {rule}),\n""", )