Import Generator from typing_extensions (1) (#118986)

This commit is contained in:
Marc Mueller 2024-06-06 17:02:13 +02:00 committed by GitHub
parent 69708db8e0
commit fe21e2b8ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 134 additions and 118 deletions

View file

@ -2,10 +2,12 @@
from __future__ import annotations
from collections.abc import Callable, Generator, Sequence
from collections.abc import Callable, Sequence
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any
from typing_extensions import Generator
from .util.event_type import EventType
if TYPE_CHECKING:
@ -138,7 +140,7 @@ class ConditionError(HomeAssistantError):
"""Return indentation."""
return " " * indent + message
def output(self, indent: int) -> Generator[str, None, None]:
def output(self, indent: int) -> Generator[str]:
"""Yield an indented representation."""
raise NotImplementedError
@ -154,7 +156,7 @@ class ConditionErrorMessage(ConditionError):
# A message describing this error
message: str
def output(self, indent: int) -> Generator[str, None, None]:
def output(self, indent: int) -> Generator[str]:
"""Yield an indented representation."""
yield self._indent(indent, f"In '{self.type}' condition: {self.message}")
@ -170,7 +172,7 @@ class ConditionErrorIndex(ConditionError):
# The error that this error wraps
error: ConditionError
def output(self, indent: int) -> Generator[str, None, None]:
def output(self, indent: int) -> Generator[str]:
"""Yield an indented representation."""
if self.total > 1:
yield self._indent(
@ -189,7 +191,7 @@ class ConditionErrorContainer(ConditionError):
# List of ConditionErrors that this error wraps
errors: Sequence[ConditionError]
def output(self, indent: int) -> Generator[str, None, None]:
def output(self, indent: int) -> Generator[str]:
"""Yield an indented representation."""
for item in self.errors:
yield from item.output(indent)