From f819be7acc9e80a46439238a48aa26b14699ecb6 Mon Sep 17 00:00:00 2001 From: jan iversen Date: Tue, 20 Jul 2021 17:26:00 +0200 Subject: [PATCH] Correct typing in Insteon and activate mypy (#53222) --- homeassistant/components/insteon/fan.py | 4 +++- homeassistant/components/insteon/ipdb.py | 2 +- homeassistant/components/insteon/schemas.py | 2 +- mypy.ini | 3 --- script/hassfest/mypy_config.py | 1 - 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/insteon/fan.py b/homeassistant/components/insteon/fan.py index 00ada3e9a58..b76661d7dde 100644 --- a/homeassistant/components/insteon/fan.py +++ b/homeassistant/components/insteon/fan.py @@ -1,4 +1,6 @@ """Support for INSTEON fans via PowerLinc Modem.""" +from __future__ import annotations + import math from homeassistant.components.fan import ( @@ -39,7 +41,7 @@ class InsteonFanEntity(InsteonEntity, FanEntity): """An INSTEON fan entity.""" @property - def percentage(self) -> int: + def percentage(self) -> int | None: """Return the current speed percentage.""" if self._insteon_device_group.value is None: return None diff --git a/homeassistant/components/insteon/ipdb.py b/homeassistant/components/insteon/ipdb.py index 48223981103..9b32bc40043 100644 --- a/homeassistant/components/insteon/ipdb.py +++ b/homeassistant/components/insteon/ipdb.py @@ -110,4 +110,4 @@ def get_device_platforms(device): def get_platform_groups(device, domain) -> dict: """Return the platforms that a device belongs in.""" - return DEVICE_PLATFORM.get(type(device), {}).get(domain, {}) + return DEVICE_PLATFORM.get(type(device), {}).get(domain, {}) # type: ignore diff --git a/homeassistant/components/insteon/schemas.py b/homeassistant/components/insteon/schemas.py index c43df24b4cb..5fb46735f29 100644 --- a/homeassistant/components/insteon/schemas.py +++ b/homeassistant/components/insteon/schemas.py @@ -161,7 +161,7 @@ TRIGGER_SCENE_SCHEMA = vol.Schema( ADD_DEFAULT_LINKS_SCHEMA = vol.Schema({vol.Required(CONF_ENTITY_ID): cv.entity_id}) -def normalize_byte_entry_to_int(entry: [int, bytes, str]): +def normalize_byte_entry_to_int(entry: int | bytes | str): """Format a hex entry value.""" if isinstance(entry, int): if entry in range(0, 256): diff --git a/mypy.ini b/mypy.ini index 9f37f46d713..4bfb8e22fe3 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1277,9 +1277,6 @@ ignore_errors = true [mypy-homeassistant.components.input_number.*] ignore_errors = true -[mypy-homeassistant.components.insteon.*] -ignore_errors = true - [mypy-homeassistant.components.ipp.*] ignore_errors = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index 666575a86ed..720c9157e14 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -84,7 +84,6 @@ IGNORED_MODULES: Final[list[str]] = [ "homeassistant.components.influxdb.*", "homeassistant.components.input_datetime.*", "homeassistant.components.input_number.*", - "homeassistant.components.insteon.*", "homeassistant.components.ipp.*", "homeassistant.components.isy994.*", "homeassistant.components.izone.*",