Deduplicate blackening (#81802)

This commit is contained in:
Aarni Koskela 2022-11-09 17:58:20 +02:00 committed by GitHub
parent f9ff23a2c8
commit f3e85b6492
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 1141 additions and 563 deletions

View file

@ -1,20 +1,8 @@
"""Generate bluetooth file."""
from __future__ import annotations
import black
from .model import Config, Integration
from .serializer import to_string
BASE = """
\"\"\"Automatically generated by hassfest.
To update, run python3 -m script.hassfest
\"\"\"
from __future__ import annotations
BLUETOOTH: list[dict[str, bool | str | int | list[int]]] = {}
""".strip()
from .serializer import format_python_namespace
def generate_and_validate(integrations: list[dict[str, str]]):
@ -35,7 +23,10 @@ def generate_and_validate(integrations: list[dict[str, str]]):
for entry in match_types:
match_list.append({"domain": domain, **entry})
return black.format_str(BASE.format(to_string(match_list)), mode=black.Mode())
return format_python_namespace(
{"BLUETOOTH": match_list},
annotations={"BLUETOOTH": "list[dict[str, bool | str | int | list[int]]]"},
)
def validate(integrations: dict[str, Integration], config: Config):