From 60b799aac94da1562a63e32d595b5bbf230be4ce Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Wed, 25 Jan 2023 11:05:36 +0100 Subject: [PATCH] Misc typing improvements (#86550) --- homeassistant/components/alexa/config.py | 5 +++-- homeassistant/components/almond/config_flow.py | 4 ++-- homeassistant/components/comfoconnect/fan.py | 2 +- homeassistant/components/coronavirus/config_flow.py | 2 +- homeassistant/components/octoprint/config_flow.py | 5 +++-- homeassistant/components/onvif/event.py | 2 +- homeassistant/components/pioneer/media_player.py | 3 ++- homeassistant/components/qwikswitch/sensor.py | 3 ++- homeassistant/components/temper/sensor.py | 2 +- homeassistant/components/yeelight/scanner.py | 2 +- 10 files changed, 17 insertions(+), 13 deletions(-) diff --git a/homeassistant/components/alexa/config.py b/homeassistant/components/alexa/config.py index 9f51d92a229..cdbea2ca346 100644 --- a/homeassistant/components/alexa/config.py +++ b/homeassistant/components/alexa/config.py @@ -1,8 +1,9 @@ """Config helpers for Alexa.""" from abc import ABC, abstractmethod +import asyncio import logging -from homeassistant.core import callback +from homeassistant.core import CALLBACK_TYPE, callback from homeassistant.helpers.storage import Store from .const import DOMAIN @@ -16,7 +17,7 @@ _LOGGER = logging.getLogger(__name__) class AbstractConfig(ABC): """Hold the configuration for Alexa.""" - _unsub_proactive_report = None + _unsub_proactive_report: asyncio.Task[CALLBACK_TYPE] | None = None def __init__(self, hass): """Initialize abstract config.""" diff --git a/homeassistant/components/almond/config_flow.py b/homeassistant/components/almond/config_flow.py index 11c883f4e0a..f0ce9377b81 100644 --- a/homeassistant/components/almond/config_flow.py +++ b/homeassistant/components/almond/config_flow.py @@ -39,8 +39,8 @@ class AlmondFlowHandler( DOMAIN = DOMAIN - host = None - hassio_discovery = None + host: str | None = None + hassio_discovery: dict[str, Any] | None = None @property def logger(self) -> logging.Logger: diff --git a/homeassistant/components/comfoconnect/fan.py b/homeassistant/components/comfoconnect/fan.py index 5341a5f6925..3f00a9b59f0 100644 --- a/homeassistant/components/comfoconnect/fan.py +++ b/homeassistant/components/comfoconnect/fan.py @@ -63,7 +63,7 @@ class ComfoConnectFan(FanEntity): _attr_should_poll = False _attr_supported_features = FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE _attr_preset_modes = PRESET_MODES - current_speed = None + current_speed: float | None = None def __init__(self, ccb: ComfoConnectBridge) -> None: """Initialize the ComfoConnect fan.""" diff --git a/homeassistant/components/coronavirus/config_flow.py b/homeassistant/components/coronavirus/config_flow.py index a5e086c90e0..81e4f06f57f 100644 --- a/homeassistant/components/coronavirus/config_flow.py +++ b/homeassistant/components/coronavirus/config_flow.py @@ -17,7 +17,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): VERSION = 1 - _options = None + _options: dict[str, Any] | None = None async def async_step_user( self, user_input: dict[str, Any] | None = None diff --git a/homeassistant/components/octoprint/config_flow.py b/homeassistant/components/octoprint/config_flow.py index c1bdc623291..33aaff8976e 100644 --- a/homeassistant/components/octoprint/config_flow.py +++ b/homeassistant/components/octoprint/config_flow.py @@ -1,6 +1,7 @@ """Config flow for OctoPrint integration.""" from __future__ import annotations +import asyncio from collections.abc import Mapping import logging from typing import Any @@ -50,8 +51,8 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): VERSION = 1 - api_key_task = None - _reauth_data = None + api_key_task: asyncio.Task[None] | None = None + _reauth_data: dict[str, Any] | None = None def __init__(self) -> None: """Handle a config flow for OctoPrint.""" diff --git a/homeassistant/components/onvif/event.py b/homeassistant/components/onvif/event.py index 4766bf0b002..54c5b3b007b 100644 --- a/homeassistant/components/onvif/event.py +++ b/homeassistant/components/onvif/event.py @@ -19,7 +19,7 @@ from .const import LOGGER from .models import Event from .parsers import PARSERS -UNHANDLED_TOPICS = set() +UNHANDLED_TOPICS: set[str] = set() SUBSCRIPTION_ERRORS = ( Fault, asyncio.TimeoutError, diff --git a/homeassistant/components/pioneer/media_player.py b/homeassistant/components/pioneer/media_player.py index 620e314fdd8..a124362251a 100644 --- a/homeassistant/components/pioneer/media_player.py +++ b/homeassistant/components/pioneer/media_player.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging import telnetlib +from typing import Final import voluptuous as vol @@ -24,7 +25,7 @@ CONF_SOURCES = "sources" DEFAULT_NAME = "Pioneer AVR" DEFAULT_PORT = 23 # telnet default. Some Pioneer AVRs use 8102 -DEFAULT_TIMEOUT = None +DEFAULT_TIMEOUT: Final = None DEFAULT_SOURCES: dict[str, str] = {} diff --git a/homeassistant/components/qwikswitch/sensor.py b/homeassistant/components/qwikswitch/sensor.py index 63cb2aa269f..8a72ca7c811 100644 --- a/homeassistant/components/qwikswitch/sensor.py +++ b/homeassistant/components/qwikswitch/sensor.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any from pyqwikswitch.qwikswitch import SENSORS @@ -34,7 +35,7 @@ async def async_setup_platform( class QSSensor(QSEntity, SensorEntity): """Sensor based on a Qwikswitch relay/dimmer module.""" - _val = None + _val: Any | None = None def __init__(self, sensor): """Initialize the sensor.""" diff --git a/homeassistant/components/temper/sensor.py b/homeassistant/components/temper/sensor.py index fd867527153..3b79ed62237 100644 --- a/homeassistant/components/temper/sensor.py +++ b/homeassistant/components/temper/sensor.py @@ -33,7 +33,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( } ) -TEMPER_SENSORS = [] +TEMPER_SENSORS: list[TemperSensor] = [] def get_temper_devices(): diff --git a/homeassistant/components/yeelight/scanner.py b/homeassistant/components/yeelight/scanner.py index 612edc29791..d988dfbcc41 100644 --- a/homeassistant/components/yeelight/scanner.py +++ b/homeassistant/components/yeelight/scanner.py @@ -35,7 +35,7 @@ _LOGGER = logging.getLogger(__name__) class YeelightScanner: """Scan for Yeelight devices.""" - _scanner = None + _scanner: YeelightScanner | None = None @classmethod @callback