Update typing (1) (#63922)
This commit is contained in:
parent
4e2cd1bec0
commit
d3b7bd25ef
11 changed files with 30 additions and 30 deletions
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||
import asyncio
|
||||
from collections import OrderedDict
|
||||
from datetime import timedelta
|
||||
from typing import Any, Dict, Mapping, Optional, Tuple, cast
|
||||
from typing import Any, Mapping, Optional, cast
|
||||
|
||||
import jwt
|
||||
|
||||
|
@ -21,9 +21,9 @@ from .providers import AuthProvider, LoginFlow, auth_provider_from_config
|
|||
EVENT_USER_ADDED = "user_added"
|
||||
EVENT_USER_REMOVED = "user_removed"
|
||||
|
||||
_MfaModuleDict = Dict[str, MultiFactorAuthModule]
|
||||
_ProviderKey = Tuple[str, Optional[str]]
|
||||
_ProviderDict = Dict[_ProviderKey, AuthProvider]
|
||||
_MfaModuleDict = dict[str, MultiFactorAuthModule]
|
||||
_ProviderKey = tuple[str, Optional[str]]
|
||||
_ProviderDict = dict[_ProviderKey, AuthProvider]
|
||||
|
||||
|
||||
class InvalidAuthError(Exception):
|
||||
|
|
|
@ -7,7 +7,7 @@ from __future__ import annotations
|
|||
import asyncio
|
||||
from collections import OrderedDict
|
||||
import logging
|
||||
from typing import Any, Dict
|
||||
from typing import Any
|
||||
|
||||
import attr
|
||||
import voluptuous as vol
|
||||
|
@ -86,7 +86,7 @@ class NotifySetting:
|
|||
target: str | None = attr.ib(default=None)
|
||||
|
||||
|
||||
_UsersDict = Dict[str, NotifySetting]
|
||||
_UsersDict = dict[str, NotifySetting]
|
||||
|
||||
|
||||
@MULTI_FACTOR_AUTH_MODULES.register("notify")
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from functools import wraps
|
||||
from typing import Callable, Dict, Optional, cast
|
||||
from typing import Callable, Optional, cast
|
||||
|
||||
from .const import SUBCAT_ALL
|
||||
from .models import PermissionLookup
|
||||
from .types import CategoryType, SubCategoryDict, ValueType
|
||||
|
||||
LookupFunc = Callable[[PermissionLookup, SubCategoryDict, str], Optional[ValueType]]
|
||||
SubCatLookupType = Dict[str, LookupFunc]
|
||||
SubCatLookupType = dict[str, LookupFunc]
|
||||
|
||||
|
||||
def lookup_all(
|
||||
|
|
|
@ -14,7 +14,7 @@ from ipaddress import (
|
|||
ip_address,
|
||||
ip_network,
|
||||
)
|
||||
from typing import Any, Dict, List, Union, cast
|
||||
from typing import Any, Union, cast
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -76,12 +76,12 @@ class TrustedNetworksAuthProvider(AuthProvider):
|
|||
@property
|
||||
def trusted_networks(self) -> list[IPNetwork]:
|
||||
"""Return trusted networks."""
|
||||
return cast(List[IPNetwork], self.config[CONF_TRUSTED_NETWORKS])
|
||||
return cast(list[IPNetwork], self.config[CONF_TRUSTED_NETWORKS])
|
||||
|
||||
@property
|
||||
def trusted_users(self) -> dict[IPNetwork, Any]:
|
||||
"""Return trusted users per network."""
|
||||
return cast(Dict[IPNetwork, Any], self.config[CONF_TRUSTED_USERS])
|
||||
return cast(dict[IPNetwork, Any], self.config[CONF_TRUSTED_USERS])
|
||||
|
||||
@property
|
||||
def trusted_proxies(self) -> list[IPNetwork]:
|
||||
|
|
|
@ -13,7 +13,7 @@ from collections.abc import Awaitable, Callable
|
|||
import logging
|
||||
import secrets
|
||||
import time
|
||||
from typing import Any, Dict, cast
|
||||
from typing import Any, cast
|
||||
|
||||
from aiohttp import client, web
|
||||
import async_timeout
|
||||
|
@ -346,7 +346,7 @@ async def async_get_implementations(
|
|||
) -> dict[str, AbstractOAuth2Implementation]:
|
||||
"""Return OAuth2 implementations for specified domain."""
|
||||
registered = cast(
|
||||
Dict[str, AbstractOAuth2Implementation],
|
||||
dict[str, AbstractOAuth2Implementation],
|
||||
hass.data.setdefault(DATA_IMPLEMENTATIONS, {}).get(domain, {}),
|
||||
)
|
||||
|
||||
|
|
|
@ -16,7 +16,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, Dict, TypeVar, cast, overload
|
||||
from typing import Any, TypeVar, cast, overload
|
||||
from urllib.parse import urlparse
|
||||
from uuid import UUID
|
||||
|
||||
|
@ -896,11 +896,11 @@ def key_value_schemas(
|
|||
key_value = value.get(key)
|
||||
|
||||
if isinstance(key_value, Hashable) and key_value in value_schemas:
|
||||
return cast(Dict[Hashable, Any], value_schemas[key_value](value))
|
||||
return cast(dict[Hashable, Any], value_schemas[key_value](value))
|
||||
|
||||
if default_schema:
|
||||
with contextlib.suppress(vol.Invalid):
|
||||
return cast(Dict[Hashable, Any], default_schema(value))
|
||||
return cast(dict[Hashable, Any], default_schema(value))
|
||||
|
||||
alternatives = ", ".join(str(key) for key in value_schemas)
|
||||
if default_description:
|
||||
|
|
|
@ -9,7 +9,7 @@ from datetime import datetime, timedelta
|
|||
import functools as ft
|
||||
import logging
|
||||
import time
|
||||
from typing import Any, Callable, List, Union, cast
|
||||
from typing import Any, Callable, Union, cast
|
||||
|
||||
import attr
|
||||
from typing_extensions import Concatenate, ParamSpec
|
||||
|
@ -1079,7 +1079,7 @@ class _TrackTemplateResultInfo:
|
|||
TrackTemplateResultListener = Callable[
|
||||
[
|
||||
Union[Event, None],
|
||||
List[TrackTemplateResult],
|
||||
list[TrackTemplateResult],
|
||||
],
|
||||
None,
|
||||
]
|
||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||
from collections.abc import Callable, Iterable
|
||||
import logging
|
||||
import re
|
||||
from typing import Any, Dict
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -16,7 +16,7 @@ from homeassistant.loader import bind_hass
|
|||
from . import config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
_SlotsType = Dict[str, Any]
|
||||
_SlotsType = dict[str, Any]
|
||||
|
||||
INTENT_TURN_OFF = "HassTurnOff"
|
||||
INTENT_TURN_ON = "HassTurnOn"
|
||||
|
|
|
@ -9,7 +9,7 @@ from functools import partial
|
|||
import itertools
|
||||
import logging
|
||||
from types import MappingProxyType
|
||||
from typing import Any, Dict, TypedDict, Union, cast
|
||||
from typing import Any, TypedDict, Union, cast
|
||||
|
||||
import async_timeout
|
||||
import voluptuous as vol
|
||||
|
@ -915,7 +915,7 @@ async def _async_stop_scripts_at_shutdown(hass, event):
|
|||
)
|
||||
|
||||
|
||||
_VarsType = Union[Dict[str, Any], MappingProxyType]
|
||||
_VarsType = Union[dict[str, Any], MappingProxyType]
|
||||
|
||||
|
||||
def _referenced_extract_ids(data: dict[str, Any], key: str, found: set[str]) -> None:
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
"""Typing Helpers for Home Assistant."""
|
||||
from enum import Enum
|
||||
from typing import Any, Dict, Mapping, Optional, Tuple, Union
|
||||
from typing import Any, Mapping, Optional, Union
|
||||
|
||||
import homeassistant.core
|
||||
|
||||
GPSType = Tuple[float, float]
|
||||
ConfigType = Dict[str, Any]
|
||||
GPSType = tuple[float, float]
|
||||
ConfigType = dict[str, Any]
|
||||
ContextType = homeassistant.core.Context
|
||||
DiscoveryInfoType = Dict[str, Any]
|
||||
DiscoveryInfoType = dict[str, Any]
|
||||
EventType = homeassistant.core.Event
|
||||
ServiceDataType = Dict[str, Any]
|
||||
ServiceDataType = dict[str, Any]
|
||||
StateType = Union[None, str, int, float]
|
||||
TemplateVarsType = Optional[Mapping[str, Any]]
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import logging
|
|||
import pathlib
|
||||
import sys
|
||||
from types import ModuleType
|
||||
from typing import TYPE_CHECKING, Any, Callable, Dict, TypedDict, TypeVar, cast
|
||||
from typing import TYPE_CHECKING, Any, Callable, TypedDict, TypeVar, cast
|
||||
|
||||
from awesomeversion import (
|
||||
AwesomeVersion,
|
||||
|
@ -159,9 +159,9 @@ async def async_get_custom_components(
|
|||
|
||||
if isinstance(reg_or_evt, asyncio.Event):
|
||||
await reg_or_evt.wait()
|
||||
return cast(Dict[str, "Integration"], hass.data.get(DATA_CUSTOM_COMPONENTS))
|
||||
return cast(dict[str, "Integration"], hass.data.get(DATA_CUSTOM_COMPONENTS))
|
||||
|
||||
return cast(Dict[str, "Integration"], reg_or_evt)
|
||||
return cast(dict[str, "Integration"], reg_or_evt)
|
||||
|
||||
|
||||
async def async_get_config_flows(hass: HomeAssistant) -> set[str]:
|
||||
|
|
Loading…
Add table
Reference in a new issue