1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Switch formatting from black to ruff-format (#102893)

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Aarni Koskela
2023-11-27 15:38:59 +02:00
committed by GitHub
parent cf9b0e804f
commit 706add4a57
161 changed files with 530 additions and 607 deletions

View File

@@ -2,11 +2,10 @@
from __future__ import annotations
from collections.abc import Collection, Iterable, Mapping
import shutil
import subprocess
from typing import Any
import black
from black.mode import Mode
DEFAULT_GENERATOR = "script.hassfest"
@@ -72,7 +71,14 @@ To update, run python3 -m {generator}
{content}
"""
return black.format_str(content.strip(), mode=Mode())
ruff = shutil.which("ruff")
if not ruff:
raise RuntimeError("ruff not found")
return subprocess.check_output(
[ruff, "format", "-"],
input=content.strip(),
encoding="utf-8",
)
def format_python_namespace(