Improve lists in integrations [N-O] (#113231)

This commit is contained in:
Joost Lekkerkerker 2024-03-13 21:51:38 +01:00 committed by GitHub
parent 595d07f1c6
commit e6a692f354
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 254 additions and 310 deletions

View file

@ -71,10 +71,11 @@ def _generate_subscription_id(cloud_project_id: str) -> str:
def generate_config_title(structures: Iterable[Structure]) -> str | None:
"""Pick a user friendly config title based on the Google Home name(s)."""
names: list[str] = []
for structure in structures:
if (trait := structure.traits.get(InfoTrait.NAME)) and trait.custom_name:
names.append(trait.custom_name)
names: list[str] = [
trait.custom_name
for structure in structures
if (trait := structure.traits.get(InfoTrait.NAME)) and trait.custom_name
]
if not names:
return None
return ", ".join(names)