Mark entity methods and properties as mandatory in pylint plugin (#145210)

* Mark entity methods and properties as mandatory in pylint plugin

* Fixes
This commit is contained in:
epenet 2025-05-19 22:47:24 +02:00 committed by GitHub
parent e76bd1bbb9
commit df3688ef08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 3 deletions

View File

@ -57,7 +57,7 @@ class CecEntity(Entity):
self._attr_available = False
self.schedule_update_ha_state(False)
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Register HDMI callbacks after initialization."""
self._device.set_update_callback(self._update)
self.hass.bus.async_listen(

View File

@ -74,7 +74,7 @@ class SmartMeterTexasSensor(CoordinatorEntity, RestoreEntity, SensorEntity):
self._attr_native_value = self.meter.reading
self.async_write_ha_state()
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Subscribe to updates."""
await super().async_added_to_hass()
self.async_on_remove(self.coordinator.async_add_listener(self._state_update))

View File

@ -605,7 +605,7 @@ class UtilityMeterSensor(RestoreSensor):
self._attr_native_value = Decimal(str(value))
self.async_write_ha_state()
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Handle entity which will be added."""
await super().async_added_to_hass()

View File

@ -667,6 +667,7 @@ _ENTITY_MATCH: list[TypeHintMatch] = [
TypeHintMatch(
function_name="should_poll",
return_type="bool",
mandatory=True,
),
TypeHintMatch(
function_name="unique_id",
@ -725,6 +726,7 @@ _ENTITY_MATCH: list[TypeHintMatch] = [
TypeHintMatch(
function_name="force_update",
return_type="bool",
mandatory=True,
),
TypeHintMatch(
function_name="supported_features",
@ -733,10 +735,12 @@ _ENTITY_MATCH: list[TypeHintMatch] = [
TypeHintMatch(
function_name="entity_registry_enabled_default",
return_type="bool",
mandatory=True,
),
TypeHintMatch(
function_name="entity_registry_visible_default",
return_type="bool",
mandatory=True,
),
TypeHintMatch(
function_name="attribution",
@ -749,23 +753,28 @@ _ENTITY_MATCH: list[TypeHintMatch] = [
TypeHintMatch(
function_name="async_removed_from_registry",
return_type=None,
mandatory=True,
),
TypeHintMatch(
function_name="async_added_to_hass",
return_type=None,
mandatory=True,
),
TypeHintMatch(
function_name="async_will_remove_from_hass",
return_type=None,
mandatory=True,
),
TypeHintMatch(
function_name="async_registry_entry_updated",
return_type=None,
mandatory=True,
),
TypeHintMatch(
function_name="update",
return_type=None,
has_async_counterpart=True,
mandatory=True,
),
]
_RESTORE_ENTITY_MATCH: list[TypeHintMatch] = [