Make hassfest strictly typed (#82091)
This commit is contained in:
parent
0b5357de44
commit
97b40b5f49
20 changed files with 132 additions and 97 deletions
|
@ -7,7 +7,7 @@ from .model import Config, Integration
|
|||
from .serializer import format_python_namespace
|
||||
|
||||
|
||||
def generate_and_validate(integrations: dict[str, Integration]):
|
||||
def generate_and_validate(integrations: dict[str, Integration]) -> str:
|
||||
"""Validate and generate MQTT data."""
|
||||
|
||||
data = defaultdict(list)
|
||||
|
@ -29,7 +29,7 @@ def generate_and_validate(integrations: dict[str, Integration]):
|
|||
return format_python_namespace({"MQTT": data})
|
||||
|
||||
|
||||
def validate(integrations: dict[str, Integration], config: Config):
|
||||
def validate(integrations: dict[str, Integration], config: Config) -> None:
|
||||
"""Validate MQTT file."""
|
||||
mqtt_path = config.root / "homeassistant/generated/mqtt.py"
|
||||
config.cache["mqtt"] = content = generate_and_validate(integrations)
|
||||
|
@ -44,10 +44,9 @@ def validate(integrations: dict[str, Integration], config: Config):
|
|||
"File mqtt.py is not up to date. Run python3 -m script.hassfest",
|
||||
fixable=True,
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
def generate(integrations: dict[str, Integration], config: Config):
|
||||
def generate(integrations: dict[str, Integration], config: Config) -> None:
|
||||
"""Generate MQTT file."""
|
||||
mqtt_path = config.root / "homeassistant/generated/mqtt.py"
|
||||
with open(str(mqtt_path), "w") as fp:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue