Activate mypy for hdmi_cec (#53763)

* Please mypy.
* Remove CEC_DEVICES.
This commit is contained in:
jan iversen 2021-07-31 23:18:37 +02:00 committed by GitHub
parent 3d52bfc8f6
commit e41bc1a0da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 12 deletions

View File

@ -1,5 +1,6 @@
"""Support for HDMI CEC."""
from collections import defaultdict
from __future__ import annotations
from functools import partial, reduce
import logging
import multiprocessing
@ -66,8 +67,6 @@ ICONS_BY_TYPE = {
5: ICON_AUDIO,
}
CEC_DEVICES = defaultdict(list)
CMD_UP = "up"
CMD_DOWN = "down"
CMD_MUTE = "mute"
@ -134,7 +133,7 @@ SERVICE_POWER_ON = "power_on"
SERVICE_STANDBY = "standby"
# pylint: disable=unnecessary-lambda
DEVICE_SCHEMA = vol.Schema(
DEVICE_SCHEMA: vol.Schema = vol.Schema(
{
vol.All(cv.positive_int): vol.Any(
lambda devices: DEVICE_SCHEMA(devices), cv.string
@ -376,7 +375,7 @@ class CecEntity(Entity):
"""Initialize the device."""
self._device = device
self._icon = None
self._state = None
self._state: str | None = None
self._logical_address = logical
self.entity_id = "%s.%d" % (DOMAIN, self._logical_address)

View File

@ -1,4 +1,6 @@
"""Support for HDMI CEC devices as media players."""
from __future__ import annotations
import logging
from pycec.commands import CecCommand, KeyPressCommand, KeyReleaseCommand
@ -149,7 +151,7 @@ class CecPlayerEntity(CecEntity, MediaPlayerEntity):
self.send_keypress(KEY_VOLUME_DOWN)
@property
def state(self) -> str:
def state(self) -> str | None:
"""Cache state of device."""
return self._state

View File

@ -1,4 +1,6 @@
"""Support for HDMI CEC devices as switches."""
from __future__ import annotations
import logging
from homeassistant.components.switch import DOMAIN, SwitchEntity
@ -56,7 +58,7 @@ class CecSwitchEntity(CecEntity, SwitchEntity):
"""Return True if entity is on."""
return self._state == STATE_ON
@property
def state(self) -> str:
@property # type: ignore
def state(self) -> str | None:
"""Return the cached state of device."""
return self._state

View File

@ -1387,9 +1387,6 @@ ignore_errors = true
[mypy-homeassistant.components.hassio.*]
ignore_errors = true
[mypy-homeassistant.components.hdmi_cec.*]
ignore_errors = true
[mypy-homeassistant.components.here_travel_time.*]
ignore_errors = true

View File

@ -62,7 +62,6 @@ IGNORED_MODULES: Final[list[str]] = [
"homeassistant.components.habitica.*",
"homeassistant.components.harmony.*",
"homeassistant.components.hassio.*",
"homeassistant.components.hdmi_cec.*",
"homeassistant.components.here_travel_time.*",
"homeassistant.components.hisense_aehw4a1.*",
"homeassistant.components.home_connect.*",