mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Enable basic type checking in demo platforms (#66212)
* Adjust type hints in demo platforms * Adjust mypy config * Adjust name
This commit is contained in:
parent
b3814aa4e6
commit
ea325ef027
@ -114,11 +114,11 @@ class BaseDemoFan(FanEntity):
|
||||
self.hass = hass
|
||||
self._unique_id = unique_id
|
||||
self._supported_features = supported_features
|
||||
self._percentage = None
|
||||
self._percentage: int | None = None
|
||||
self._preset_modes = preset_modes
|
||||
self._preset_mode = None
|
||||
self._oscillating = None
|
||||
self._direction = None
|
||||
self._preset_mode: str | None = None
|
||||
self._oscillating: bool | None = None
|
||||
self._direction: str | None = None
|
||||
self._name = name
|
||||
if supported_features & SUPPORT_OSCILLATE:
|
||||
self._oscillating = False
|
||||
@ -141,12 +141,12 @@ class BaseDemoFan(FanEntity):
|
||||
return False
|
||||
|
||||
@property
|
||||
def current_direction(self) -> str:
|
||||
def current_direction(self) -> str | None:
|
||||
"""Fan direction."""
|
||||
return self._direction
|
||||
|
||||
@property
|
||||
def oscillating(self) -> bool:
|
||||
def oscillating(self) -> bool | None:
|
||||
"""Oscillating."""
|
||||
return self._oscillating
|
||||
|
||||
@ -257,7 +257,7 @@ class AsyncDemoPercentageFan(BaseDemoFan, FanEntity):
|
||||
|
||||
async def async_set_preset_mode(self, preset_mode: str) -> None:
|
||||
"""Set new preset mode."""
|
||||
if preset_mode not in self.preset_modes:
|
||||
if self.preset_modes is None or preset_mode not in self.preset_modes:
|
||||
raise ValueError(
|
||||
"{preset_mode} is not a valid preset_mode: {self.preset_modes}"
|
||||
)
|
||||
|
@ -195,17 +195,17 @@ class DemoLight(LightEntity):
|
||||
return self._color_mode
|
||||
|
||||
@property
|
||||
def hs_color(self) -> tuple:
|
||||
def hs_color(self) -> tuple[float, float]:
|
||||
"""Return the hs color value."""
|
||||
return self._hs_color
|
||||
|
||||
@property
|
||||
def rgbw_color(self) -> tuple:
|
||||
def rgbw_color(self) -> tuple[int, int, int, int]:
|
||||
"""Return the rgbw color value."""
|
||||
return self._rgbw_color
|
||||
|
||||
@property
|
||||
def rgbww_color(self) -> tuple:
|
||||
def rgbww_color(self) -> tuple[int, int, int, int, int]:
|
||||
"""Return the rgbww color value."""
|
||||
return self._rgbww_color
|
||||
|
||||
|
@ -105,13 +105,10 @@ class DemoNumber(NumberEntity):
|
||||
if step is not None:
|
||||
self._attr_step = step
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device info."""
|
||||
return DeviceInfo(
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={
|
||||
# Serial numbers are unique identifiers within a specific domain
|
||||
(DOMAIN, self.unique_id)
|
||||
(DOMAIN, unique_id)
|
||||
},
|
||||
name=self.name,
|
||||
)
|
||||
|
@ -46,7 +46,7 @@ class DemoRemote(RemoteEntity):
|
||||
self._attr_name = name or DEVICE_DEFAULT_NAME
|
||||
self._attr_is_on = state
|
||||
self._attr_icon = icon
|
||||
self._last_command_sent = None
|
||||
self._last_command_sent: str | None = None
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict[str, Any] | None:
|
||||
|
@ -54,7 +54,7 @@ class DemoSiren(SirenEntity):
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
available_tones: str | None = None,
|
||||
available_tones: list[str | int] | None = None,
|
||||
support_volume_set: bool = False,
|
||||
support_duration: bool = False,
|
||||
is_on: bool = True,
|
||||
|
@ -64,12 +64,8 @@ class DemoSwitch(SwitchEntity):
|
||||
self._attr_is_on = state
|
||||
self._attr_name = name or DEVICE_DEFAULT_NAME
|
||||
self._attr_unique_id = unique_id
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device info."""
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.unique_id)},
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, unique_id)},
|
||||
name=self.name,
|
||||
)
|
||||
|
||||
|
18
mypy.ini
18
mypy.ini
@ -2196,24 +2196,6 @@ ignore_errors = true
|
||||
[mypy-homeassistant.components.deconz.switch]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.demo.fan]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.demo.light]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.demo.number]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.demo.remote]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.demo.siren]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.demo.switch]
|
||||
ignore_errors = true
|
||||
|
||||
[mypy-homeassistant.components.denonavr.config_flow]
|
||||
ignore_errors = true
|
||||
|
||||
|
@ -38,12 +38,6 @@ IGNORED_MODULES: Final[list[str]] = [
|
||||
"homeassistant.components.deconz.services",
|
||||
"homeassistant.components.deconz.siren",
|
||||
"homeassistant.components.deconz.switch",
|
||||
"homeassistant.components.demo.fan",
|
||||
"homeassistant.components.demo.light",
|
||||
"homeassistant.components.demo.number",
|
||||
"homeassistant.components.demo.remote",
|
||||
"homeassistant.components.demo.siren",
|
||||
"homeassistant.components.demo.switch",
|
||||
"homeassistant.components.denonavr.config_flow",
|
||||
"homeassistant.components.denonavr.media_player",
|
||||
"homeassistant.components.denonavr.receiver",
|
||||
|
Loading…
x
Reference in New Issue
Block a user