Skip to content

Commit 3476e2f

Browse files
authored
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
1 parent 8848eca commit 3476e2f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

scripts/add_rule.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ def main(*, name: str, prefix: str, code: str, linter: str) -> None:
137137
lines.append(line)
138138

139139
variant = pascal_case(linter)
140-
rule = f"""rules::{linter.split(" ")[0]}::rules::{name}"""
140+
linter_name = linter.split(" ")[0].replace("-", "_")
141+
rule = f"""rules::{linter_name}::rules::{name}"""
141142
lines.append(
142143
" " * 8 + f"""({variant}, "{code}") => (RuleGroup::Preview, {rule}),\n""",
143144
)

0 commit comments

Comments
 (0)