From 86a8ab91301bf49445b1d3e0c990a1e5d46e77ad Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Thu, 24 Jun 2021 09:55:35 +0200 Subject: [PATCH] Fix bad typing for LogLevel (#45) * Fix bad typing for LogLevel * Lint --- aioesphomeapi/client.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/aioesphomeapi/client.py b/aioesphomeapi/client.py index 720932b..31c1427 100644 --- a/aioesphomeapi/client.py +++ b/aioesphomeapi/client.py @@ -1,6 +1,17 @@ import asyncio import logging -from typing import Any, Awaitable, Callable, Dict, List, Optional, Tuple, Union, cast +from typing import ( + TYPE_CHECKING, + Any, + Awaitable, + Callable, + Dict, + List, + Optional, + Tuple, + Union, + cast, +) import attr import zeroconf @@ -36,7 +47,6 @@ from aioesphomeapi.api_pb2 import ( # type: ignore ListEntitiesServicesResponse, ListEntitiesSwitchResponse, ListEntitiesTextSensorResponse, - LogLevel, SensorStateResponse, SubscribeHomeassistantServicesRequest, SubscribeHomeAssistantStateResponse, @@ -85,6 +95,9 @@ from aioesphomeapi.model import ( UserServiceArgType, ) +if TYPE_CHECKING: + from aioesphomeapi.api_pb2 import LogLevel # type: ignore + _LOGGER = logging.getLogger(__name__) ExecuteServiceDataType = Dict[ @@ -289,7 +302,7 @@ class APIClient: async def subscribe_logs( self, on_log: Callable[[SubscribeLogsResponse], None], - log_level: Optional[LogLevel] = None, + log_level: Optional["LogLevel"] = None, ) -> None: self._check_authenticated()