Misc typing improvements (#86550)

This commit is contained in:
Marc Mueller 2023-01-25 11:05:36 +01:00 committed by GitHub
parent 0e9b74986f
commit 60b799aac9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 17 additions and 13 deletions

View File

@ -1,8 +1,9 @@
"""Config helpers for Alexa.""" """Config helpers for Alexa."""
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
import asyncio
import logging import logging
from homeassistant.core import callback from homeassistant.core import CALLBACK_TYPE, callback
from homeassistant.helpers.storage import Store from homeassistant.helpers.storage import Store
from .const import DOMAIN from .const import DOMAIN
@ -16,7 +17,7 @@ _LOGGER = logging.getLogger(__name__)
class AbstractConfig(ABC): class AbstractConfig(ABC):
"""Hold the configuration for Alexa.""" """Hold the configuration for Alexa."""
_unsub_proactive_report = None _unsub_proactive_report: asyncio.Task[CALLBACK_TYPE] | None = None
def __init__(self, hass): def __init__(self, hass):
"""Initialize abstract config.""" """Initialize abstract config."""

View File

@ -39,8 +39,8 @@ class AlmondFlowHandler(
DOMAIN = DOMAIN DOMAIN = DOMAIN
host = None host: str | None = None
hassio_discovery = None hassio_discovery: dict[str, Any] | None = None
@property @property
def logger(self) -> logging.Logger: def logger(self) -> logging.Logger:

View File

@ -63,7 +63,7 @@ class ComfoConnectFan(FanEntity):
_attr_should_poll = False _attr_should_poll = False
_attr_supported_features = FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE _attr_supported_features = FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE
_attr_preset_modes = PRESET_MODES _attr_preset_modes = PRESET_MODES
current_speed = None current_speed: float | None = None
def __init__(self, ccb: ComfoConnectBridge) -> None: def __init__(self, ccb: ComfoConnectBridge) -> None:
"""Initialize the ComfoConnect fan.""" """Initialize the ComfoConnect fan."""

View File

@ -17,7 +17,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
VERSION = 1 VERSION = 1
_options = None _options: dict[str, Any] | None = None
async def async_step_user( async def async_step_user(
self, user_input: dict[str, Any] | None = None self, user_input: dict[str, Any] | None = None

View File

@ -1,6 +1,7 @@
"""Config flow for OctoPrint integration.""" """Config flow for OctoPrint integration."""
from __future__ import annotations from __future__ import annotations
import asyncio
from collections.abc import Mapping from collections.abc import Mapping
import logging import logging
from typing import Any from typing import Any
@ -50,8 +51,8 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
VERSION = 1 VERSION = 1
api_key_task = None api_key_task: asyncio.Task[None] | None = None
_reauth_data = None _reauth_data: dict[str, Any] | None = None
def __init__(self) -> None: def __init__(self) -> None:
"""Handle a config flow for OctoPrint.""" """Handle a config flow for OctoPrint."""

View File

@ -19,7 +19,7 @@ from .const import LOGGER
from .models import Event from .models import Event
from .parsers import PARSERS from .parsers import PARSERS
UNHANDLED_TOPICS = set() UNHANDLED_TOPICS: set[str] = set()
SUBSCRIPTION_ERRORS = ( SUBSCRIPTION_ERRORS = (
Fault, Fault,
asyncio.TimeoutError, asyncio.TimeoutError,

View File

@ -3,6 +3,7 @@ from __future__ import annotations
import logging import logging
import telnetlib import telnetlib
from typing import Final
import voluptuous as vol import voluptuous as vol
@ -24,7 +25,7 @@ CONF_SOURCES = "sources"
DEFAULT_NAME = "Pioneer AVR" DEFAULT_NAME = "Pioneer AVR"
DEFAULT_PORT = 23 # telnet default. Some Pioneer AVRs use 8102 DEFAULT_PORT = 23 # telnet default. Some Pioneer AVRs use 8102
DEFAULT_TIMEOUT = None DEFAULT_TIMEOUT: Final = None
DEFAULT_SOURCES: dict[str, str] = {} DEFAULT_SOURCES: dict[str, str] = {}

View File

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any
from pyqwikswitch.qwikswitch import SENSORS from pyqwikswitch.qwikswitch import SENSORS
@ -34,7 +35,7 @@ async def async_setup_platform(
class QSSensor(QSEntity, SensorEntity): class QSSensor(QSEntity, SensorEntity):
"""Sensor based on a Qwikswitch relay/dimmer module.""" """Sensor based on a Qwikswitch relay/dimmer module."""
_val = None _val: Any | None = None
def __init__(self, sensor): def __init__(self, sensor):
"""Initialize the sensor.""" """Initialize the sensor."""

View File

@ -33,7 +33,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
} }
) )
TEMPER_SENSORS = [] TEMPER_SENSORS: list[TemperSensor] = []
def get_temper_devices(): def get_temper_devices():

View File

@ -35,7 +35,7 @@ _LOGGER = logging.getLogger(__name__)
class YeelightScanner: class YeelightScanner:
"""Scan for Yeelight devices.""" """Scan for Yeelight devices."""
_scanner = None _scanner: YeelightScanner | None = None
@classmethod @classmethod
@callback @callback