Enable strict typing for rfxtrx (#74927)

* Additional typing

* Enable strict typing

* Avoid changes causing coverage change

* Adjust comment on force update

* Rename to replace_devices

* Reduce typing scope

* Adjust mypy
This commit is contained in:
Joakim Plate 2022-09-23 16:47:58 +02:00 committed by GitHub
parent 67779089cd
commit ace9592aa1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 190 additions and 101 deletions

View file

@ -10,6 +10,7 @@ from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_COMMAND_OFF, CONF_COMMAND_ON, STATE_ON
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import (
@ -31,7 +32,7 @@ DATA_SWITCH = f"{DOMAIN}_switch"
_LOGGER = logging.getLogger(__name__)
def supported(event):
def supported(event: rfxtrxmod.RFXtrxEvent) -> bool:
"""Return whether an event supports switch."""
return (
isinstance(event.device, rfxtrxmod.LightingDevice)
@ -52,8 +53,8 @@ async def async_setup_entry(
event: rfxtrxmod.RFXtrxEvent,
auto: rfxtrxmod.RFXtrxEvent | None,
device_id: DeviceTuple,
entity_info: dict,
):
entity_info: dict[str, Any],
) -> list[Entity]:
return [
RfxtrxSwitch(
event.device,
@ -97,7 +98,7 @@ class RfxtrxSwitch(RfxtrxCommandEntity, SwitchEntity):
if old_state is not None:
self._attr_is_on = old_state.state == STATE_ON
def _apply_event_lighting4(self, event: rfxtrxmod.RFXtrxEvent):
def _apply_event_lighting4(self, event: rfxtrxmod.RFXtrxEvent) -> None:
"""Apply event for a lighting 4 device."""
if self._data_bits is not None:
cmdstr = get_pt2262_cmd(event.device.id_string, self._data_bits)