Deduplicate blackening (#81802)
This commit is contained in:
parent
f9ff23a2c8
commit
f3e85b6492
19 changed files with 1141 additions and 563 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue