mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 12:29:48 +00:00
refactor: Introduce get_indent helper for scripts
This commit is contained in:
parent
67ca50e9f2
commit
ff6defc988
3 changed files with 12 additions and 10 deletions
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
ROOT_DIR = Path(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
@ -11,3 +12,7 @@ def dir_name(origin: str) -> str:
|
|||
def pascal_case(origin: str) -> str:
|
||||
"""Convert from snake-case to PascalCase."""
|
||||
return "".join(word.title() for word in origin.split("-"))
|
||||
|
||||
|
||||
def get_indent(line: str) -> str:
|
||||
return re.match(r"^\s*", line).group() # pyright: ignore[reportOptionalMemberAccess]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue