Mark type hint as compulsory for entity.available property (#145189)

pull/145113/merge
epenet 2025-05-19 11:50:41 +02:00 committed by GitHub
parent f27b2c4df1
commit 8d83341308
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 19 additions and 18 deletions

View File

@ -165,7 +165,7 @@ class MediaroomDevice(MediaPlayerEntity):
self._unique_id = None
@property
def available(self):
def available(self) -> bool:
"""Return True if entity is available."""
return self._available

View File

@ -279,7 +279,7 @@ class Luminary(LightEntity):
return self._device_attributes
@property
def available(self):
def available(self) -> bool:
"""Return True if entity is available."""
return self._available

View File

@ -156,7 +156,7 @@ class RMVDepartureSensor(SensorEntity):
return self._name
@property
def available(self):
def available(self) -> bool:
"""Return True if entity is available."""
return self._state is not None

View File

@ -64,7 +64,7 @@ class SonyProjector(SwitchEntity):
self._attributes = {}
@property
def available(self):
def available(self) -> bool:
"""Return if projector is available."""
return self._available

View File

@ -64,7 +64,7 @@ class StarlineButton(StarlineEntity, ButtonEntity):
self.entity_description = description
@property
def available(self):
def available(self) -> bool:
"""Return True if entity is available."""
return super().available and self._device.online

View File

@ -71,7 +71,7 @@ class SupervisorProcessSensor(SensorEntity):
return self._info.get("statename")
@property
def available(self):
def available(self) -> bool:
"""Could the device be accessed during the last update call."""
return self._available

View File

@ -111,7 +111,7 @@ class FolderSensor(SensorEntity):
return self._state["state"]
@property
def available(self):
def available(self) -> bool:
"""Could the device be accessed during the last update call."""
return self._state is not None

View File

@ -95,7 +95,7 @@ class TfiacClimate(ClimateEntity):
self._available = True
@property
def available(self):
def available(self) -> bool:
"""Return if the device is available."""
return self._available

View File

@ -86,7 +86,7 @@ class VSensor(SensorEntity):
return self._unit
@property
def available(self):
def available(self) -> bool:
"""Return if the sensor is available."""
return self._available

View File

@ -84,7 +84,7 @@ class VActuator(SwitchEntity):
return self._is_on
@property
def available(self):
def available(self) -> bool:
"""Return if the actuator is available."""
return self._available

View File

@ -44,7 +44,7 @@ class BoolEntity(WiffiEntity, BinarySensorEntity):
self.reset_expiration_date()
@property
def available(self):
def available(self) -> bool:
"""Return true if value is valid."""
return self._attr_is_on is not None

View File

@ -86,7 +86,7 @@ class NumberEntity(WiffiEntity, SensorEntity):
self.reset_expiration_date()
@property
def available(self):
def available(self) -> bool:
"""Return true if value is valid."""
return self._attr_native_value is not None
@ -116,7 +116,7 @@ class StringEntity(WiffiEntity, SensorEntity):
self.reset_expiration_date()
@property
def available(self):
def available(self) -> bool:
"""Return true if value is valid."""
return self._attr_native_value is not None

View File

@ -271,7 +271,7 @@ class XiaomiPhilipsAbstractLight(XiaomiMiioEntity, LightEntity):
self._state_attrs = {}
@property
def available(self):
def available(self) -> bool:
"""Return true when state is known."""
return self._available
@ -1027,7 +1027,7 @@ class XiaomiGatewayLight(LightEntity):
return self._name
@property
def available(self):
def available(self) -> bool:
"""Return true when state is known."""
return self._available

View File

@ -928,7 +928,7 @@ class XiaomiAirQualityMonitor(XiaomiMiioEntity, SensorEntity):
self.entity_description = description
@property
def available(self):
def available(self) -> bool:
"""Return true when state is known."""
return self._available
@ -1001,7 +1001,7 @@ class XiaomiGatewayIlluminanceSensor(SensorEntity):
self._state = None
@property
def available(self):
def available(self) -> bool:
"""Return true when state is known."""
return self._available

View File

@ -789,7 +789,7 @@ class XiaomiPlugGenericSwitch(XiaomiMiioEntity, SwitchEntity):
return self._icon
@property
def available(self):
def available(self) -> bool:
"""Return true when state is known."""
return self._available

View File

@ -676,6 +676,7 @@ _ENTITY_MATCH: list[TypeHintMatch] = [
TypeHintMatch(
function_name="available",
return_type="bool",
mandatory=True,
),
TypeHintMatch(
function_name="assumed_state",