Improve select type hints (#76446)

This commit is contained in:
epenet 2022-08-08 15:22:22 +02:00 committed by GitHub
parent 3026a70f96
commit fe9c101817
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -46,11 +46,11 @@ class AdvantageAirMyZone(AdvantageAirAcEntity, SelectEntity):
self._attr_options.append(zone["name"]) self._attr_options.append(zone["name"])
@property @property
def current_option(self): def current_option(self) -> str:
"""Return the current MyZone.""" """Return the current MyZone."""
return self._number_to_name[self._ac["myZone"]] return self._number_to_name[self._ac["myZone"]]
async def async_select_option(self, option): async def async_select_option(self, option: str) -> None:
"""Set the MyZone.""" """Set the MyZone."""
await self.async_change( await self.async_change(
{self.ac_key: {"info": {"myZone": self._name_to_number[option]}}} {self.ac_key: {"info": {"myZone": self._name_to_number[option]}}}

View File

@ -164,7 +164,7 @@ class XiaomiAirHumidifierSelector(XiaomiSelector):
self.async_write_ha_state() self.async_write_ha_state()
@property @property
def current_option(self): def current_option(self) -> str:
"""Return the current option.""" """Return the current option."""
return self.led_brightness.lower() return self.led_brightness.lower()

View File

@ -52,11 +52,11 @@ class SelectableCapapility(MusicCastCapabilityEntity, SelectEntity):
return DEVICE_CLASS_MAPPING.get(self.capability.id) return DEVICE_CLASS_MAPPING.get(self.capability.id)
@property @property
def options(self): def options(self) -> list[str]:
"""Return the list possible options.""" """Return the list possible options."""
return list(self.capability.options.values()) return list(self.capability.options.values())
@property @property
def current_option(self): def current_option(self) -> str | None:
"""Return the currently selected option.""" """Return the currently selected option."""
return self.capability.options.get(self.capability.current) return self.capability.options.get(self.capability.current)