Improve iterable typing (1) (#79295)

This commit is contained in:
Marc Mueller 2022-10-01 00:12:39 +02:00 committed by GitHub
parent fbcf6cb03c
commit 3a9ecab98a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 10 deletions

View File

@ -1,7 +1,7 @@
"""Provide pre-made queries on top of the recorder component.""" """Provide pre-made queries on top of the recorder component."""
from __future__ import annotations from __future__ import annotations
from collections.abc import Callable, Iterable from collections.abc import Callable, Collection, Iterable
import json import json
from typing import Any from typing import Any
@ -81,13 +81,13 @@ class Filters:
def __init__(self) -> None: def __init__(self) -> None:
"""Initialise the include and exclude filters.""" """Initialise the include and exclude filters."""
self.excluded_entities: Iterable[str] = [] self.excluded_entities: Collection[str] = []
self.excluded_domains: Iterable[str] = [] self.excluded_domains: Collection[str] = []
self.excluded_entity_globs: Iterable[str] = [] self.excluded_entity_globs: Collection[str] = []
self.included_entities: Iterable[str] = [] self.included_entities: Collection[str] = []
self.included_domains: Iterable[str] = [] self.included_domains: Collection[str] = []
self.included_entity_globs: Iterable[str] = [] self.included_entity_globs: Collection[str] = []
def __repr__(self) -> str: def __repr__(self) -> str:
"""Return human readable excludes/includes.""" """Return human readable excludes/includes."""

View File

@ -1,7 +1,7 @@
"""SQLAlchemy util functions.""" """SQLAlchemy util functions."""
from __future__ import annotations from __future__ import annotations
from collections.abc import Callable, Generator, Iterable from collections.abc import Callable, Generator
from contextlib import contextmanager from contextlib import contextmanager
from datetime import date, datetime, timedelta from datetime import date, datetime, timedelta
import functools import functools
@ -180,7 +180,7 @@ def execute_stmt_lambda_element(
start_time: datetime | None = None, start_time: datetime | None = None,
end_time: datetime | None = None, end_time: datetime | None = None,
yield_per: int | None = DEFAULT_YIELD_STATES_ROWS, yield_per: int | None = DEFAULT_YIELD_STATES_ROWS,
) -> Iterable[Row]: ) -> list[Row]:
"""Execute a StatementLambdaElement. """Execute a StatementLambdaElement.
If the time window passed is greater than one day If the time window passed is greater than one day

View File

@ -649,7 +649,7 @@ class HomeAssistant:
else: else:
await asyncio.sleep(0) await asyncio.sleep(0)
async def _await_and_log_pending(self, pending: Iterable[Awaitable[Any]]) -> None: async def _await_and_log_pending(self, pending: Collection[Awaitable[Any]]) -> None:
"""Await and log tasks that take a long time.""" """Await and log tasks that take a long time."""
wait_time = 0 wait_time = 0
while pending: while pending: