mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 22:07:10 +00:00
Enable disallow-any-generics in number (#78502)
This commit is contained in:
parent
eae384bbf7
commit
b56eabc35b
@ -78,10 +78,12 @@ VALID_UNITS: dict[str, tuple[str, ...]] = {
|
|||||||
NumberDeviceClass.TEMPERATURE: temperature_util.VALID_UNITS,
|
NumberDeviceClass.TEMPERATURE: temperature_util.VALID_UNITS,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# mypy: disallow-any-generics
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up Number entities."""
|
"""Set up Number entities."""
|
||||||
component = hass.data[DOMAIN] = EntityComponent(
|
component = hass.data[DOMAIN] = EntityComponent[NumberEntity](
|
||||||
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
|
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
|
||||||
)
|
)
|
||||||
await component.async_setup(config)
|
await component.async_setup(config)
|
||||||
@ -115,13 +117,13 @@ async def async_set_value(entity: NumberEntity, service_call: ServiceCall) -> No
|
|||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up a config entry."""
|
"""Set up a config entry."""
|
||||||
component: EntityComponent = hass.data[DOMAIN]
|
component: EntityComponent[NumberEntity] = hass.data[DOMAIN]
|
||||||
return await component.async_setup_entry(entry)
|
return await component.async_setup_entry(entry)
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
component: EntityComponent = hass.data[DOMAIN]
|
component: EntityComponent[NumberEntity] = hass.data[DOMAIN]
|
||||||
return await component.async_unload_entry(entry)
|
return await component.async_unload_entry(entry)
|
||||||
|
|
||||||
|
|
||||||
@ -423,7 +425,9 @@ class NumberEntity(Entity):
|
|||||||
"""Set new value."""
|
"""Set new value."""
|
||||||
await self.hass.async_add_executor_job(self.set_value, value)
|
await self.hass.async_add_executor_job(self.set_value, value)
|
||||||
|
|
||||||
def _convert_to_state_value(self, value: float, method: Callable) -> float:
|
def _convert_to_state_value(
|
||||||
|
self, value: float, method: Callable[[float, int], float]
|
||||||
|
) -> float:
|
||||||
"""Convert a value in the number's native unit to the configured unit."""
|
"""Convert a value in the number's native unit to the configured unit."""
|
||||||
|
|
||||||
native_unit_of_measurement = self.native_unit_of_measurement
|
native_unit_of_measurement = self.native_unit_of_measurement
|
||||||
|
Loading…
x
Reference in New Issue
Block a user