mirror of
				https://github.com/astral-sh/ruff.git
				synced 2025-10-30 11:36:57 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
	
		
			667 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
	
		
			667 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from __future__ import annotations
 | |
| 
 | |
| import re
 | |
| from pathlib import Path
 | |
| 
 | |
| ROOT_DIR = Path(__file__).resolve().parent.parent
 | |
| 
 | |
| 
 | |
| def dir_name(linter_name: str) -> str:
 | |
|     return linter_name.replace("-", "_")
 | |
| 
 | |
| 
 | |
| def pascal_case(linter_name: str) -> str:
 | |
|     """Convert from snake-case to PascalCase."""
 | |
|     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]
 | 
