From 283c04e4246239f618fd897cced1c51d576d7b74 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Thu, 28 Apr 2022 10:52:42 +0200 Subject: [PATCH] Improve typing [helpers.entity] (#70890) --- .strict-typing | 1 + homeassistant/helpers/entity.py | 6 +++--- mypy.ini | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.strict-typing b/.strict-typing index bb2a163f40d..ea4124abde5 100644 --- a/.strict-typing +++ b/.strict-typing @@ -16,6 +16,7 @@ homeassistant.auth.providers.* homeassistant.helpers.area_registry homeassistant.helpers.condition homeassistant.helpers.discovery +homeassistant.helpers.entity homeassistant.helpers.entity_values homeassistant.helpers.event homeassistant.helpers.reload diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index 791a80f7731..f07f4c1c7b8 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -3,7 +3,7 @@ from __future__ import annotations from abc import ABC import asyncio -from collections.abc import Awaitable, Iterable, Mapping, MutableMapping +from collections.abc import Coroutine, Iterable, Mapping, MutableMapping from dataclasses import dataclass from datetime import datetime, timedelta from enum import Enum, auto @@ -621,7 +621,7 @@ class Entity(ABC): if DATA_CUSTOMIZE in self.hass.data: attr.update(self.hass.data[DATA_CUSTOMIZE].get(self.entity_id)) - def _convert_temperature(state: str, attr: dict) -> str: + def _convert_temperature(state: str, attr: dict[str, Any]) -> str: # Convert temperature if we detect one # pylint: disable-next=import-outside-toplevel from homeassistant.components.sensor import SensorEntity @@ -958,7 +958,7 @@ class Entity(ABC): """Return the representation.""" return f"" - async def async_request_call(self, coro: Awaitable) -> None: + async def async_request_call(self, coro: Coroutine[Any, Any, Any]) -> None: """Process request batched.""" if self.parallel_updates: await self.parallel_updates.acquire() diff --git a/mypy.ini b/mypy.ini index 5df02c46252..74ed61e5c57 100644 --- a/mypy.ini +++ b/mypy.ini @@ -60,6 +60,9 @@ disallow_any_generics = true [mypy-homeassistant.helpers.discovery] disallow_any_generics = true +[mypy-homeassistant.helpers.entity] +disallow_any_generics = true + [mypy-homeassistant.helpers.entity_values] disallow_any_generics = true