mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 19:09:32 +00:00
Enable Ruff PTH for the script directory (#124441)
* Enable Ruff PTH for the script directory * Address review comments * Fix translations script * Update script/hassfest/config_flow.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> --------- Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pathlib
|
||||
from typing import Any
|
||||
|
||||
from .brand import validate as validate_brands
|
||||
@@ -216,36 +215,31 @@ def validate(integrations: dict[str, Integration], config: Config) -> None:
|
||||
if config.specific_integrations:
|
||||
return
|
||||
|
||||
brands = Brand.load_dir(pathlib.Path(config.root / "homeassistant/brands"), config)
|
||||
brands = Brand.load_dir(config.root / "homeassistant/brands", config)
|
||||
validate_brands(brands, integrations, config)
|
||||
|
||||
with open(str(config_flow_path)) as fp:
|
||||
if fp.read() != content:
|
||||
config.add_error(
|
||||
"config_flow",
|
||||
"File config_flows.py is not up to date. "
|
||||
"Run python3 -m script.hassfest",
|
||||
fixable=True,
|
||||
)
|
||||
if config_flow_path.read_text() != content:
|
||||
config.add_error(
|
||||
"config_flow",
|
||||
"File config_flows.py is not up to date. Run python3 -m script.hassfest",
|
||||
fixable=True,
|
||||
)
|
||||
|
||||
config.cache["integrations"] = content = _generate_integrations(
|
||||
brands, integrations, config
|
||||
)
|
||||
with open(str(integrations_path)) as fp:
|
||||
if fp.read() != content + "\n":
|
||||
config.add_error(
|
||||
"config_flow",
|
||||
"File integrations.json is not up to date. "
|
||||
"Run python3 -m script.hassfest",
|
||||
fixable=True,
|
||||
)
|
||||
if integrations_path.read_text() != content + "\n":
|
||||
config.add_error(
|
||||
"config_flow",
|
||||
"File integrations.json is not up to date. "
|
||||
"Run python3 -m script.hassfest",
|
||||
fixable=True,
|
||||
)
|
||||
|
||||
|
||||
def generate(integrations: dict[str, Integration], config: Config) -> None:
|
||||
"""Generate config flow file."""
|
||||
config_flow_path = config.root / "homeassistant/generated/config_flows.py"
|
||||
integrations_path = config.root / "homeassistant/generated/integrations.json"
|
||||
with open(str(config_flow_path), "w") as fp:
|
||||
fp.write(f"{config.cache['config_flow']}")
|
||||
with open(str(integrations_path), "w") as fp:
|
||||
fp.write(f"{config.cache['integrations']}\n")
|
||||
config_flow_path.write_text(f"{config.cache['config_flow']}")
|
||||
integrations_path.write_text(f"{config.cache['integrations']}\n")
|
||||
|
||||
Reference in New Issue
Block a user