Use black to format hassfest generated files (#78794)
This commit is contained in:
parent
e66f28f3f7
commit
1021c90bb8
19 changed files with 633 additions and 624 deletions
|
@ -1,9 +1,10 @@
|
|||
"""Generate application_credentials data."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import black
|
||||
|
||||
from .model import Config, Integration
|
||||
from .serializer import to_string
|
||||
|
||||
BASE = """
|
||||
\"\"\"Automatically generated by hassfest.
|
||||
|
@ -11,8 +12,6 @@ BASE = """
|
|||
To update, run python3 -m script.hassfest
|
||||
\"\"\"
|
||||
|
||||
# fmt: off
|
||||
|
||||
APPLICATION_CREDENTIALS = {}
|
||||
""".strip()
|
||||
|
||||
|
@ -30,7 +29,7 @@ def generate_and_validate(integrations: dict[str, Integration], config: Config)
|
|||
|
||||
match_list.append(domain)
|
||||
|
||||
return BASE.format(json.dumps(match_list, indent=4))
|
||||
return black.format_str(BASE.format(to_string(match_list)), mode=black.Mode())
|
||||
|
||||
|
||||
def validate(integrations: dict[str, Integration], config: Config) -> None:
|
||||
|
@ -45,7 +44,7 @@ def validate(integrations: dict[str, Integration], config: Config) -> None:
|
|||
if config.specific_integrations:
|
||||
return
|
||||
|
||||
if application_credentials_path.read_text(encoding="utf-8").strip() != content:
|
||||
if application_credentials_path.read_text(encoding="utf-8") != content:
|
||||
config.add_error(
|
||||
"application_credentials",
|
||||
"File application_credentials.py is not up to date. Run python3 -m script.hassfest",
|
||||
|
@ -59,5 +58,5 @@ def generate(integrations: dict[str, Integration], config: Config):
|
|||
config.root / "homeassistant/generated/application_credentials.py"
|
||||
)
|
||||
application_credentials_path.write_text(
|
||||
f"{config.cache['application_credentials']}\n", encoding="utf-8"
|
||||
f"{config.cache['application_credentials']}", encoding="utf-8"
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue