mirror of
https://github.com/home-assistant/core.git
synced 2025-12-27 14:31:13 +00:00
Deduplicate blackening (#81802)
This commit is contained in:
@@ -3,24 +3,8 @@ from __future__ import annotations
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
import black
|
||||
|
||||
from .model import Config, Integration
|
||||
from .serializer import to_string
|
||||
|
||||
BASE = """
|
||||
\"\"\"Automatically generated by hassfest.
|
||||
|
||||
To update, run python3 -m script.hassfest
|
||||
\"\"\"
|
||||
|
||||
SSDP = {}
|
||||
""".strip()
|
||||
|
||||
|
||||
def sort_dict(value):
|
||||
"""Sort a dictionary."""
|
||||
return {key: value[key] for key in sorted(value)}
|
||||
from .serializer import format_python_namespace
|
||||
|
||||
|
||||
def generate_and_validate(integrations: dict[str, Integration]):
|
||||
@@ -40,9 +24,9 @@ def generate_and_validate(integrations: dict[str, Integration]):
|
||||
continue
|
||||
|
||||
for matcher in ssdp:
|
||||
data[domain].append(sort_dict(matcher))
|
||||
data[domain].append(matcher)
|
||||
|
||||
return black.format_str(BASE.format(to_string(data)), mode=black.Mode())
|
||||
return format_python_namespace({"SSDP": data})
|
||||
|
||||
|
||||
def validate(integrations: dict[str, Integration], config: Config):
|
||||
|
||||
Reference in New Issue
Block a user