Skip to content

Commit

Permalink
Import Callable from collections.abc (1) (home-assistant#56775)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p authored Sep 29, 2021
1 parent d51487f commit 77ee72c
Show file tree
Hide file tree
Showing 36 changed files with 73 additions and 58 deletions.
3 changes: 2 additions & 1 deletion homeassistant/auth/permissions/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/auth/permissions/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/helpers/aiohttp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/helpers/config_entry_oauth2_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

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
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/helpers/config_validation.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -15,7 +15,7 @@
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

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/helpers/debounce.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion homeassistant/helpers/deprecation.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 2 additions & 1 deletion homeassistant/helpers/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"""
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
Expand Down
5 changes: 4 additions & 1 deletion homeassistant/helpers/dispatcher.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/helpers/entity_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/helpers/entity_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/helpers/entity_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
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

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/helpers/entityfilter.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 2 additions & 1 deletion homeassistant/helpers/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion homeassistant/helpers/httpx_client.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/helpers/integration_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/helpers/intent.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/helpers/ratelimit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/helpers/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/helpers/selector.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/helpers/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions homeassistant/helpers/start.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/helpers/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/helpers/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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
Expand All @@ -17,7 +17,7 @@
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

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/helpers/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/helpers/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/helpers/update_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/scripts/benchmark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
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
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/scripts/check_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
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
Expand Down
Loading

0 comments on commit 77ee72c

Please sign in to comment.