Update typing - collections.abc (1) (#63933)
* Update typing - collections.abc (1) * Additional typing updates
This commit is contained in:
parent
789c0a24dd
commit
12757a8cd2
14 changed files with 38 additions and 23 deletions
|
@ -3,8 +3,9 @@ from __future__ import annotations
|
|||
|
||||
import asyncio
|
||||
from collections import OrderedDict
|
||||
from collections.abc import Mapping
|
||||
from datetime import timedelta
|
||||
from typing import Any, Mapping, Optional, cast
|
||||
from typing import Any, Optional, cast
|
||||
|
||||
import jwt
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
"""Common code for permissions."""
|
||||
from typing import Mapping, Union
|
||||
from collections.abc import Mapping
|
||||
from typing import Union
|
||||
|
||||
# MyPy doesn't support recursion yet. So writing it out as far as we need.
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
"""Helpers to deal with permissions."""
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
from functools import wraps
|
||||
from typing import Callable, Optional, cast
|
||||
from typing import Optional, cast
|
||||
|
||||
from .const import SUBCAT_ALL
|
||||
from .models import PermissionLookup
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections.abc import Iterable, Mapping
|
||||
from collections.abc import Callable, Iterable, Mapping
|
||||
from contextvars import ContextVar
|
||||
import dataclasses
|
||||
from enum import Enum
|
||||
import functools
|
||||
import logging
|
||||
from types import MappingProxyType, MethodType
|
||||
from typing import TYPE_CHECKING, Any, Callable, Optional, TypeVar, cast
|
||||
from typing import TYPE_CHECKING, Any, Optional, TypeVar, cast
|
||||
import weakref
|
||||
|
||||
from . import data_entry_flow, loader
|
||||
|
|
|
@ -7,7 +7,14 @@ of entities and react to changes.
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections.abc import Collection, Coroutine, Iterable, Mapping
|
||||
from collections.abc import (
|
||||
Awaitable,
|
||||
Callable,
|
||||
Collection,
|
||||
Coroutine,
|
||||
Iterable,
|
||||
Mapping,
|
||||
)
|
||||
import datetime
|
||||
import enum
|
||||
import functools
|
||||
|
@ -21,8 +28,6 @@ from types import MappingProxyType
|
|||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
Awaitable,
|
||||
Callable,
|
||||
Generic,
|
||||
NamedTuple,
|
||||
Optional,
|
||||
|
|
|
@ -3,11 +3,11 @@ from __future__ import annotations
|
|||
|
||||
from abc import ABC, abstractmethod
|
||||
import asyncio
|
||||
from collections.abc import Coroutine
|
||||
from collections.abc import Awaitable, Callable, Coroutine, Iterable
|
||||
from dataclasses import dataclass
|
||||
from itertools import groupby
|
||||
import logging
|
||||
from typing import Any, Awaitable, Callable, Iterable, Optional, cast
|
||||
from typing import Any, Optional, cast
|
||||
|
||||
import voluptuous as vol
|
||||
from voluptuous.humanize import humanize_error
|
||||
|
|
|
@ -3,14 +3,14 @@ from __future__ import annotations
|
|||
|
||||
import asyncio
|
||||
from collections import deque
|
||||
from collections.abc import Container, Generator
|
||||
from collections.abc import Callable, Container, Generator
|
||||
from contextlib import contextmanager
|
||||
from datetime import datetime, time as dt_time, timedelta
|
||||
import functools as ft
|
||||
import logging
|
||||
import re
|
||||
import sys
|
||||
from typing import Any, Callable, cast
|
||||
from typing import Any, cast
|
||||
|
||||
from homeassistant.components import zone as zone_cmp
|
||||
from homeassistant.components.device_automation import (
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
"""Helpers for data entry flows for config entries."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio # pylint: disable=unused-import # used in cast as string
|
||||
from collections.abc import Awaitable, Callable
|
||||
import logging
|
||||
from typing import Any, Awaitable, Callable, Union, cast
|
||||
from typing import TYPE_CHECKING, Any, Union, cast
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp, mqtt, ssdp, zeroconf
|
||||
|
@ -12,6 +12,9 @@ from homeassistant.data_entry_flow import FlowResult
|
|||
|
||||
from .typing import UNDEFINED, DiscoveryInfoType, UndefinedType
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import asyncio
|
||||
|
||||
DiscoveryFunctionType = Callable[[HomeAssistant], Union[Awaitable[bool], bool]]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections.abc import Awaitable, Iterable, Sequence
|
||||
from collections.abc import Awaitable, Callable, Iterable, Sequence
|
||||
import copy
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime, timedelta
|
||||
import functools as ft
|
||||
import logging
|
||||
import time
|
||||
from typing import Any, Callable, Union, cast
|
||||
from typing import Any, Union, cast
|
||||
|
||||
import attr
|
||||
from typing_extensions import Concatenate, ParamSpec
|
||||
|
|
|
@ -28,8 +28,9 @@ The following cases will never be passed to your function:
|
|||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
from types import MappingProxyType
|
||||
from typing import Any, Callable, Optional, Union
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
from homeassistant.const import STATE_UNAVAILABLE, STATE_UNKNOWN
|
||||
from homeassistant.core import HomeAssistant, State, callback
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections.abc import Callable
|
||||
import functools
|
||||
from typing import Callable, TypeVar, cast
|
||||
from typing import TypeVar, cast
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.loader import bind_hass
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Typing Helpers for Home Assistant."""
|
||||
from collections.abc import Mapping
|
||||
from enum import Enum
|
||||
from typing import Any, Mapping, Optional, Union
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import homeassistant.core
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ documentation as possible to keep it understandable.
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections.abc import Callable
|
||||
from contextlib import suppress
|
||||
import functools as ft
|
||||
import importlib
|
||||
|
@ -15,7 +16,7 @@ import logging
|
|||
import pathlib
|
||||
import sys
|
||||
from types import ModuleType
|
||||
from typing import TYPE_CHECKING, Any, Callable, TypedDict, TypeVar, cast
|
||||
from typing import TYPE_CHECKING, Any, TypedDict, TypeVar, cast
|
||||
|
||||
from awesomeversion import (
|
||||
AwesomeVersion,
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections.abc import Coroutine
|
||||
from collections.abc import Awaitable, Callable, Coroutine
|
||||
from functools import partial, wraps
|
||||
import inspect
|
||||
import logging
|
||||
import logging.handlers
|
||||
import queue
|
||||
import traceback
|
||||
from typing import Any, Awaitable, Callable, cast, overload
|
||||
from typing import Any, cast, overload
|
||||
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE
|
||||
from homeassistant.core import HomeAssistant, callback, is_callback
|
||||
|
@ -106,7 +106,7 @@ def log_exception(format_err: Callable[..., Any], *args: Any) -> None:
|
|||
|
||||
|
||||
@overload
|
||||
def catch_log_exception( # type: ignore
|
||||
def catch_log_exception( # type: ignore[misc]
|
||||
func: Callable[..., Awaitable[Any]], format_err: Callable[..., Any], *args: Any
|
||||
) -> Callable[..., Awaitable[None]]:
|
||||
"""Overload for Callables that return an Awaitable."""
|
||||
|
|
Loading…
Add table
Reference in a new issue