mirror of
https://github.com/home-assistant/core.git
synced 2025-11-12 20:40:18 +00:00
Migrate legacy typehints in core to PEP-526 (#26403)
* Migrate legacy typehints in core to PEP-526 * Fix one type
This commit is contained in:
committed by
Paulus Schoutsen
parent
2dc90be94f
commit
2f0eb07624
@@ -5,16 +5,7 @@ import json
|
||||
import logging
|
||||
from collections import defaultdict
|
||||
from types import ModuleType, TracebackType
|
||||
from typing import ( # noqa: F401 pylint: disable=unused-import
|
||||
Awaitable,
|
||||
Dict,
|
||||
Iterable,
|
||||
List,
|
||||
Optional,
|
||||
Tuple,
|
||||
Type,
|
||||
Union,
|
||||
)
|
||||
from typing import Awaitable, Dict, Iterable, List, Optional, Tuple, Type, Union
|
||||
|
||||
from homeassistant.loader import bind_hass, async_get_integration, IntegrationNotFound
|
||||
import homeassistant.util.dt as dt_util
|
||||
@@ -99,7 +90,7 @@ class AsyncTrackStates:
|
||||
def __init__(self, hass: HomeAssistantType) -> None:
|
||||
"""Initialize a TrackStates block."""
|
||||
self.hass = hass
|
||||
self.states = [] # type: List[State]
|
||||
self.states: List[State] = []
|
||||
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
def __enter__(self) -> List[State]:
|
||||
@@ -147,7 +138,7 @@ async def async_reproduce_state(
|
||||
if isinstance(states, State):
|
||||
states = [states]
|
||||
|
||||
to_call = defaultdict(list) # type: Dict[str, List[State]]
|
||||
to_call: Dict[str, List[State]] = defaultdict(list)
|
||||
|
||||
for state in states:
|
||||
to_call[state.domain].append(state)
|
||||
@@ -191,7 +182,7 @@ async def async_reproduce_state_legacy(
|
||||
context: Optional[Context] = None,
|
||||
) -> None:
|
||||
"""Reproduce given state."""
|
||||
to_call = defaultdict(list) # type: Dict[Tuple[str, str], List[str]]
|
||||
to_call: Dict[Tuple[str, str], List[str]] = defaultdict(list)
|
||||
|
||||
if domain == GROUP_DOMAIN:
|
||||
service_domain = HASS_DOMAIN
|
||||
@@ -238,7 +229,7 @@ async def async_reproduce_state_legacy(
|
||||
key = (service, json.dumps(dict(state.attributes), sort_keys=True))
|
||||
to_call[key].append(state.entity_id)
|
||||
|
||||
domain_tasks = [] # type: List[Awaitable[Optional[bool]]]
|
||||
domain_tasks: List[Awaitable[Optional[bool]]] = []
|
||||
for (service, service_data), entity_ids in to_call.items():
|
||||
data = json.loads(service_data)
|
||||
data[ATTR_ENTITY_ID] = entity_ids
|
||||
|
||||
Reference in New Issue
Block a user