diff --git a/homeassistant/auth/permissions/__init__.py b/homeassistant/auth/permissions/__init__.py index 898a8334234..694ea2b7379 100644 --- a/homeassistant/auth/permissions/__init__.py +++ b/homeassistant/auth/permissions/__init__.py @@ -1,8 +1,9 @@ """Permissions for Home Assistant.""" from __future__ import annotations +from collections.abc import Callable import logging -from typing import Any, Callable +from typing import Any import voluptuous as vol diff --git a/homeassistant/auth/permissions/entities.py b/homeassistant/auth/permissions/entities.py index f19590a6349..3f2a0c14f19 100644 --- a/homeassistant/auth/permissions/entities.py +++ b/homeassistant/auth/permissions/entities.py @@ -2,7 +2,7 @@ from __future__ import annotations from collections import OrderedDict -from typing import Callable +from collections.abc import Callable import voluptuous as vol diff --git a/homeassistant/config.py b/homeassistant/config.py index a51fe711ea5..540336eeca3 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -2,14 +2,14 @@ from __future__ import annotations from collections import OrderedDict -from collections.abc import Sequence +from collections.abc import Callable, Sequence import logging import os from pathlib import Path import re import shutil from types import ModuleType -from typing import Any, Callable +from typing import Any from urllib.parse import urlparse from awesomeversion import AwesomeVersion diff --git a/homeassistant/helpers/aiohttp_client.py b/homeassistant/helpers/aiohttp_client.py index 696f2d40cb8..c7f77bf086d 100644 --- a/homeassistant/helpers/aiohttp_client.py +++ b/homeassistant/helpers/aiohttp_client.py @@ -2,12 +2,12 @@ from __future__ import annotations import asyncio -from collections.abc import Awaitable +from collections.abc import Awaitable, Callable from contextlib import suppress from ssl import SSLContext import sys from types import MappingProxyType -from typing import Any, Callable, cast +from typing import Any, cast import aiohttp from aiohttp import web diff --git a/homeassistant/helpers/config_entry_oauth2_flow.py b/homeassistant/helpers/config_entry_oauth2_flow.py index a3a00d46df3..014c1f4f272 100644 --- a/homeassistant/helpers/config_entry_oauth2_flow.py +++ b/homeassistant/helpers/config_entry_oauth2_flow.py @@ -9,11 +9,11 @@ from __future__ import annotations from abc import ABC, ABCMeta, abstractmethod import asyncio -from collections.abc import Awaitable +from collections.abc import Awaitable, Callable import logging import secrets import time -from typing import Any, Callable, Dict, cast +from typing import Any, Dict, cast from aiohttp import client, web import async_timeout diff --git a/homeassistant/helpers/config_validation.py b/homeassistant/helpers/config_validation.py index 3a2fb6c70e4..4bfcb98e9d4 100644 --- a/homeassistant/helpers/config_validation.py +++ b/homeassistant/helpers/config_validation.py @@ -1,7 +1,7 @@ """Helpers for config validation using voluptuous.""" from __future__ import annotations -from collections.abc import Hashable +from collections.abc import Callable, Hashable from datetime import ( date as date_sys, datetime as datetime_sys, @@ -15,7 +15,7 @@ from numbers import Number import os import re from socket import _GLOBAL_DEFAULT_TIMEOUT # type: ignore # private, not in typeshed -from typing import Any, Callable, Dict, TypeVar, cast +from typing import Any, Dict, TypeVar, cast from urllib.parse import urlparse from uuid import UUID diff --git a/homeassistant/helpers/debounce.py b/homeassistant/helpers/debounce.py index 75e0215d2cb..e3f13e3ad16 100644 --- a/homeassistant/helpers/debounce.py +++ b/homeassistant/helpers/debounce.py @@ -2,9 +2,9 @@ from __future__ import annotations import asyncio -from collections.abc import Awaitable +from collections.abc import Awaitable, Callable from logging import Logger -from typing import Any, Callable +from typing import Any from homeassistant.core import HassJob, HomeAssistant, callback diff --git a/homeassistant/helpers/deprecation.py b/homeassistant/helpers/deprecation.py index e20748913ba..4bf57c1a4e1 100644 --- a/homeassistant/helpers/deprecation.py +++ b/homeassistant/helpers/deprecation.py @@ -1,10 +1,11 @@ """Deprecation helpers for Home Assistant.""" from __future__ import annotations +from collections.abc import Callable import functools import inspect import logging -from typing import Any, Callable +from typing import Any from ..helpers.frame import MissingIntegrationFrame, get_integration_frame diff --git a/homeassistant/helpers/discovery.py b/homeassistant/helpers/discovery.py index 53dbca867d7..3f7523e9299 100644 --- a/homeassistant/helpers/discovery.py +++ b/homeassistant/helpers/discovery.py @@ -7,7 +7,8 @@ There are two different types of discoveries that can be fired/listened for. """ from __future__ import annotations -from typing import Any, Callable, TypedDict +from collections.abc import Callable +from typing import Any, TypedDict from homeassistant import core, setup from homeassistant.core import CALLBACK_TYPE diff --git a/homeassistant/helpers/dispatcher.py b/homeassistant/helpers/dispatcher.py index 2b365412e27..d1f7b2b97f9 100644 --- a/homeassistant/helpers/dispatcher.py +++ b/homeassistant/helpers/dispatcher.py @@ -1,6 +1,9 @@ """Helpers for Home Assistant dispatcher & internal component/platform.""" +from __future__ import annotations + +from collections.abc import Callable import logging -from typing import Any, Callable +from typing import Any from homeassistant.core import HassJob, HomeAssistant, callback from homeassistant.loader import bind_hass diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index 7f329d02133..d65f485166b 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -2,12 +2,12 @@ from __future__ import annotations import asyncio -from collections.abc import Iterable +from collections.abc import Callable, Iterable from datetime import timedelta from itertools import chain import logging from types import ModuleType -from typing import Any, Callable +from typing import Any import voluptuous as vol diff --git a/homeassistant/helpers/entity_platform.py b/homeassistant/helpers/entity_platform.py index 778b7f3747d..c212645325c 100644 --- a/homeassistant/helpers/entity_platform.py +++ b/homeassistant/helpers/entity_platform.py @@ -2,13 +2,13 @@ from __future__ import annotations import asyncio -from collections.abc import Coroutine, Iterable +from collections.abc import Callable, Coroutine, Iterable from contextvars import ContextVar from datetime import datetime, timedelta import logging from logging import Logger from types import ModuleType -from typing import TYPE_CHECKING, Any, Callable, Protocol +from typing import TYPE_CHECKING, Any, Protocol import voluptuous as vol diff --git a/homeassistant/helpers/entity_registry.py b/homeassistant/helpers/entity_registry.py index 5d1c495904b..88233b30df7 100644 --- a/homeassistant/helpers/entity_registry.py +++ b/homeassistant/helpers/entity_registry.py @@ -10,9 +10,9 @@ timer. from __future__ import annotations from collections import OrderedDict -from collections.abc import Iterable, Mapping +from collections.abc import Callable, Iterable, Mapping import logging -from typing import TYPE_CHECKING, Any, Callable, cast +from typing import TYPE_CHECKING, Any, cast import attr diff --git a/homeassistant/helpers/entityfilter.py b/homeassistant/helpers/entityfilter.py index e026955f286..727231dde00 100644 --- a/homeassistant/helpers/entityfilter.py +++ b/homeassistant/helpers/entityfilter.py @@ -1,9 +1,9 @@ """Helper class to implement include/exclude of entities and domains.""" from __future__ import annotations +from collections.abc import Callable import fnmatch import re -from typing import Callable import voluptuous as vol diff --git a/homeassistant/helpers/frame.py b/homeassistant/helpers/frame.py index f10e8f4c25c..7d29d78dc54 100644 --- a/homeassistant/helpers/frame.py +++ b/homeassistant/helpers/frame.py @@ -2,10 +2,11 @@ from __future__ import annotations import asyncio +from collections.abc import Callable import functools import logging from traceback import FrameSummary, extract_stack -from typing import Any, Callable, TypeVar, cast +from typing import Any, TypeVar, cast from homeassistant.exceptions import HomeAssistantError diff --git a/homeassistant/helpers/httpx_client.py b/homeassistant/helpers/httpx_client.py index cc4f5be47d8..ec5b0a5e7ca 100644 --- a/homeassistant/helpers/httpx_client.py +++ b/homeassistant/helpers/httpx_client.py @@ -1,8 +1,9 @@ """Helper for httpx.""" from __future__ import annotations +from collections.abc import Callable import sys -from typing import Any, Callable +from typing import Any import httpx diff --git a/homeassistant/helpers/integration_platform.py b/homeassistant/helpers/integration_platform.py index 57a81083c50..0e619fe551b 100644 --- a/homeassistant/helpers/integration_platform.py +++ b/homeassistant/helpers/integration_platform.py @@ -2,9 +2,9 @@ from __future__ import annotations import asyncio -from collections.abc import Awaitable +from collections.abc import Awaitable, Callable import logging -from typing import Any, Callable +from typing import Any from homeassistant.core import Event, HomeAssistant from homeassistant.loader import async_get_integration, bind_hass diff --git a/homeassistant/helpers/intent.py b/homeassistant/helpers/intent.py index cfc89240b78..c25cc25e99b 100644 --- a/homeassistant/helpers/intent.py +++ b/homeassistant/helpers/intent.py @@ -1,10 +1,10 @@ """Module to coordinate user intentions.""" from __future__ import annotations -from collections.abc import Iterable +from collections.abc import Callable, Iterable import logging import re -from typing import Any, Callable, Dict +from typing import Any, Dict import voluptuous as vol diff --git a/homeassistant/helpers/ratelimit.py b/homeassistant/helpers/ratelimit.py index 389b3f4d2d5..350f50423e1 100644 --- a/homeassistant/helpers/ratelimit.py +++ b/homeassistant/helpers/ratelimit.py @@ -2,10 +2,10 @@ from __future__ import annotations import asyncio -from collections.abc import Hashable +from collections.abc import Callable, Hashable from datetime import datetime, timedelta import logging -from typing import Any, Callable +from typing import Any from homeassistant.core import HomeAssistant, callback import homeassistant.util.dt as dt_util diff --git a/homeassistant/helpers/script.py b/homeassistant/helpers/script.py index e5e8ef4fd52..c43b918c59d 100644 --- a/homeassistant/helpers/script.py +++ b/homeassistant/helpers/script.py @@ -2,14 +2,14 @@ from __future__ import annotations import asyncio -from collections.abc import Sequence +from collections.abc import Callable, Sequence from contextlib import asynccontextmanager, suppress from datetime import datetime, timedelta from functools import partial import itertools import logging from types import MappingProxyType -from typing import Any, Callable, Dict, TypedDict, Union, cast +from typing import Any, Dict, TypedDict, Union, cast import async_timeout import voluptuous as vol diff --git a/homeassistant/helpers/selector.py b/homeassistant/helpers/selector.py index 5bde59c06dc..6258d6db1c3 100644 --- a/homeassistant/helpers/selector.py +++ b/homeassistant/helpers/selector.py @@ -1,7 +1,8 @@ """Selectors for Home Assistant.""" from __future__ import annotations -from typing import Any, Callable, cast +from collections.abc import Callable +from typing import Any, cast import voluptuous as vol diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index ed07c6bda63..002d6447441 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -2,11 +2,11 @@ from __future__ import annotations import asyncio -from collections.abc import Awaitable, Iterable +from collections.abc import Awaitable, Callable, Iterable import dataclasses from functools import partial, wraps import logging -from typing import TYPE_CHECKING, Any, Callable, TypedDict +from typing import TYPE_CHECKING, Any, TypedDict import voluptuous as vol diff --git a/homeassistant/helpers/start.py b/homeassistant/helpers/start.py index e7e827ec5c3..805ac193834 100644 --- a/homeassistant/helpers/start.py +++ b/homeassistant/helpers/start.py @@ -1,6 +1,7 @@ """Helpers to help during startup.""" -from collections.abc import Awaitable -from typing import Callable +from __future__ import annotations + +from collections.abc import Awaitable, Callable from homeassistant.const import EVENT_HOMEASSISTANT_START from homeassistant.core import Event, HomeAssistant, callback diff --git a/homeassistant/helpers/storage.py b/homeassistant/helpers/storage.py index 0d5e24b3b40..116c9186149 100644 --- a/homeassistant/helpers/storage.py +++ b/homeassistant/helpers/storage.py @@ -2,11 +2,12 @@ from __future__ import annotations import asyncio +from collections.abc import Callable from contextlib import suppress from json import JSONEncoder import logging import os -from typing import Any, Callable +from typing import Any from homeassistant.const import EVENT_HOMEASSISTANT_FINAL_WRITE from homeassistant.core import CALLBACK_TYPE, CoreState, Event, HomeAssistant, callback diff --git a/homeassistant/helpers/template.py b/homeassistant/helpers/template.py index 94323c14f56..831400feaf9 100644 --- a/homeassistant/helpers/template.py +++ b/homeassistant/helpers/template.py @@ -5,7 +5,7 @@ from ast import literal_eval import asyncio import base64 import collections.abc -from collections.abc import Generator, Iterable +from collections.abc import Callable, Generator, Iterable from contextlib import suppress from contextvars import ContextVar from datetime import datetime, timedelta @@ -17,7 +17,7 @@ from operator import attrgetter import random import re import sys -from typing import Any, Callable, cast +from typing import Any, cast from urllib.parse import urlencode as urllib_urlencode import weakref diff --git a/homeassistant/helpers/trace.py b/homeassistant/helpers/trace.py index 58b0dc19d43..0c364124c50 100644 --- a/homeassistant/helpers/trace.py +++ b/homeassistant/helpers/trace.py @@ -2,11 +2,11 @@ from __future__ import annotations from collections import deque -from collections.abc import Generator +from collections.abc import Callable, Generator from contextlib import contextmanager from contextvars import ContextVar from functools import wraps -from typing import Any, Callable, cast +from typing import Any, cast from homeassistant.helpers.typing import TemplateVarsType import homeassistant.util.dt as dt_util diff --git a/homeassistant/helpers/trigger.py b/homeassistant/helpers/trigger.py index 9d431cdb7b8..c7ef6d31be4 100644 --- a/homeassistant/helpers/trigger.py +++ b/homeassistant/helpers/trigger.py @@ -2,8 +2,9 @@ from __future__ import annotations import asyncio +from collections.abc import Callable import logging -from typing import Any, Callable +from typing import Any import voluptuous as vol diff --git a/homeassistant/helpers/update_coordinator.py b/homeassistant/helpers/update_coordinator.py index 2203ab240ef..a48fca8a01f 100644 --- a/homeassistant/helpers/update_coordinator.py +++ b/homeassistant/helpers/update_coordinator.py @@ -2,11 +2,11 @@ from __future__ import annotations import asyncio -from collections.abc import Awaitable +from collections.abc import Awaitable, Callable from datetime import datetime, timedelta import logging from time import monotonic -from typing import Callable, Generic, TypeVar +from typing import Generic, TypeVar import urllib.error import aiohttp diff --git a/homeassistant/scripts/benchmark/__init__.py b/homeassistant/scripts/benchmark/__init__.py index 2acefbce128..1005b48e1ca 100644 --- a/homeassistant/scripts/benchmark/__init__.py +++ b/homeassistant/scripts/benchmark/__init__.py @@ -4,12 +4,13 @@ from __future__ import annotations import argparse import asyncio import collections +from collections.abc import Callable from contextlib import suppress from datetime import datetime import json import logging from timeit import default_timer as timer -from typing import Callable, TypeVar +from typing import TypeVar from homeassistant import core from homeassistant.components.websocket_api.const import JSON_DUMP diff --git a/homeassistant/scripts/check_config.py b/homeassistant/scripts/check_config.py index ac3208aad19..8e683bb5a1b 100644 --- a/homeassistant/scripts/check_config.py +++ b/homeassistant/scripts/check_config.py @@ -4,11 +4,11 @@ from __future__ import annotations import argparse import asyncio from collections import OrderedDict -from collections.abc import Mapping, Sequence +from collections.abc import Callable, Mapping, Sequence from glob import glob import logging import os -from typing import Any, Callable +from typing import Any from unittest.mock import patch from homeassistant import core diff --git a/homeassistant/setup.py b/homeassistant/setup.py index 1c372394c43..a917eb65b69 100644 --- a/homeassistant/setup.py +++ b/homeassistant/setup.py @@ -2,12 +2,11 @@ from __future__ import annotations import asyncio -from collections.abc import Awaitable, Generator, Iterable +from collections.abc import Awaitable, Callable, Generator, Iterable import contextlib import logging.handlers from timeit import default_timer as timer from types import ModuleType -from typing import Callable from homeassistant import config as conf_util, core, loader, requirements from homeassistant.config import async_notify_setup_error diff --git a/homeassistant/util/__init__.py b/homeassistant/util/__init__.py index 60f3e409f06..4f7f1af2e7d 100644 --- a/homeassistant/util/__init__.py +++ b/homeassistant/util/__init__.py @@ -2,7 +2,7 @@ from __future__ import annotations import asyncio -from collections.abc import Coroutine, Iterable, KeysView +from collections.abc import Callable, Coroutine, Iterable, KeysView from datetime import datetime, timedelta import enum from functools import lru_cache, wraps @@ -12,7 +12,7 @@ import socket import string import threading from types import MappingProxyType -from typing import Any, Callable, TypeVar +from typing import Any, TypeVar import slugify as unicode_slug diff --git a/homeassistant/util/async_.py b/homeassistant/util/async_.py index 86308b48f7a..bf7250b68e6 100644 --- a/homeassistant/util/async_.py +++ b/homeassistant/util/async_.py @@ -3,13 +3,13 @@ from __future__ import annotations from asyncio import Semaphore, coroutines, ensure_future, gather, get_running_loop from asyncio.events import AbstractEventLoop -from collections.abc import Awaitable, Coroutine +from collections.abc import Awaitable, Callable, Coroutine import concurrent.futures import functools import logging import threading from traceback import extract_stack -from typing import Any, Callable, TypeVar +from typing import Any, TypeVar _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/util/decorator.py b/homeassistant/util/decorator.py index d2943d39979..602cdba5598 100644 --- a/homeassistant/util/decorator.py +++ b/homeassistant/util/decorator.py @@ -1,6 +1,8 @@ """Decorator utility functions.""" -from collections.abc import Hashable -from typing import Callable, TypeVar +from __future__ import annotations + +from collections.abc import Callable, Hashable +from typing import TypeVar CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable) # pylint: disable=invalid-name diff --git a/homeassistant/util/distance.py b/homeassistant/util/distance.py index 6b21e9b4c47..38b9253ffbf 100644 --- a/homeassistant/util/distance.py +++ b/homeassistant/util/distance.py @@ -1,8 +1,8 @@ """Distance util functions.""" from __future__ import annotations +from collections.abc import Callable from numbers import Number -from typing import Callable from homeassistant.const import ( LENGTH, diff --git a/homeassistant/util/json.py b/homeassistant/util/json.py index fac008d9f0f..e82bd968754 100644 --- a/homeassistant/util/json.py +++ b/homeassistant/util/json.py @@ -2,11 +2,12 @@ from __future__ import annotations from collections import deque +from collections.abc import Callable import json import logging import os import tempfile -from typing import Any, Callable +from typing import Any from homeassistant.core import Event, State from homeassistant.exceptions import HomeAssistantError