Skip to content

Commit

Permalink
fixes invalid rule from hyphen (#11484)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
ekohilas committed May 22, 2024
1 parent 8848eca commit 3476e2f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/add_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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""",
)
Expand Down

0 comments on commit 3476e2f

Please sign in to comment.