mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:39:12 +00:00
Improve add_rule.py
and add_plugin.py
scripts (#3725)
This commit is contained in:
parent
2659336ed1
commit
fec4fa39a7
4 changed files with 126 additions and 49 deletions
|
@ -13,5 +13,12 @@ def pascal_case(linter_name: str) -> str:
|
|||
return "".join(word.title() for word in linter_name.split("-"))
|
||||
|
||||
|
||||
def snake_case(name: str) -> str:
|
||||
"""Convert from PascalCase to snake_case."""
|
||||
return "".join(
|
||||
f"_{word.lower()}" if word.isupper() else word for word in name
|
||||
).lstrip("_")
|
||||
|
||||
|
||||
def get_indent(line: str) -> str:
|
||||
return re.match(r"^\s*", line).group() # type: ignore[union-attr]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue