diff --git a/homeassistant/generated/bluetooth.py b/homeassistant/generated/bluetooth.py index 3c18c27057a..03b40ad258f 100644 --- a/homeassistant/generated/bluetooth.py +++ b/homeassistant/generated/bluetooth.py @@ -5,7 +5,9 @@ To update, run python3 -m script.hassfest from __future__ import annotations -BLUETOOTH: list[dict[str, bool | str | int | list[int]]] = [ +from typing import Final + +BLUETOOTH: Final[list[dict[str, bool | str | int | list[int]]]] = [ { "domain": "airthings_ble", "manufacturer_id": 820, diff --git a/homeassistant/generated/countries.py b/homeassistant/generated/countries.py index 452e65afb02..c3c912c4882 100644 --- a/homeassistant/generated/countries.py +++ b/homeassistant/generated/countries.py @@ -7,7 +7,11 @@ to the political situation in the world, please contact the ISO 3166 working gro """ -COUNTRIES = { +from __future__ import annotations + +from typing import Final + +COUNTRIES: Final[set[str]] = { "AD", "AE", "AF", diff --git a/homeassistant/generated/dhcp.py b/homeassistant/generated/dhcp.py index 9c5d25a7f22..3b5fe9843f2 100644 --- a/homeassistant/generated/dhcp.py +++ b/homeassistant/generated/dhcp.py @@ -5,7 +5,9 @@ To update, run python3 -m script.hassfest from __future__ import annotations -DHCP: list[dict[str, str | bool]] = [ +from typing import Final + +DHCP: Final[list[dict[str, str | bool]]] = [ { "domain": "airzone", "macaddress": "E84F25*", diff --git a/script/countries.py b/script/countries.py index d67caa4da65..b6ec99c9e28 100644 --- a/script/countries.py +++ b/script/countries.py @@ -24,5 +24,6 @@ Path("homeassistant/generated/countries.py").write_text( "COUNTRIES": countries, }, generator=generator_string, + annotations={"COUNTRIES": "Final[set[str]]"}, ) ) diff --git a/script/hassfest/bluetooth.py b/script/hassfest/bluetooth.py index d724905f9cd..49480d1ed02 100644 --- a/script/hassfest/bluetooth.py +++ b/script/hassfest/bluetooth.py @@ -20,7 +20,9 @@ def generate_and_validate(integrations: dict[str, Integration]) -> str: return format_python_namespace( {"BLUETOOTH": match_list}, - annotations={"BLUETOOTH": "list[dict[str, bool | str | int | list[int]]]"}, + annotations={ + "BLUETOOTH": "Final[list[dict[str, bool | str | int | list[int]]]]" + }, ) diff --git a/script/hassfest/dhcp.py b/script/hassfest/dhcp.py index 67543a772fc..d1fd0474430 100644 --- a/script/hassfest/dhcp.py +++ b/script/hassfest/dhcp.py @@ -20,7 +20,7 @@ def generate_and_validate(integrations: dict[str, Integration]) -> str: return format_python_namespace( {"DHCP": match_list}, - annotations={"DHCP": "list[dict[str, str | bool]]"}, + annotations={"DHCP": "Final[list[dict[str, str | bool]]]"}, ) diff --git a/script/hassfest/serializer.py b/script/hassfest/serializer.py index 1de4c48a0c4..d81a0621ecb 100644 --- a/script/hassfest/serializer.py +++ b/script/hassfest/serializer.py @@ -102,6 +102,6 @@ def format_python_namespace( for key, value in sorted(content.items()) ) if annotations: - # If we had any annotations, add the __future__ import. - code = f"from __future__ import annotations\n{code}" + # If we had any annotations, add __future__ and typing imports. + code = f"from __future__ import annotations\n\nfrom typing import Final\n{code}" return format_python(code, generator=generator)