Small typing improvements (#126818)
* Add from __future__ import annotations * Use PEP 695 type aliases * Fix generator typingpull/126824/head
parent
cf803507d6
commit
c1b24e6ba2
|
@ -1,5 +1,7 @@
|
|||
"""Media source for Google Photos."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from enum import StrEnum
|
||||
import logging
|
||||
|
@ -46,7 +48,7 @@ class PhotosIdentifierType(StrEnum):
|
|||
ALBUM = "a"
|
||||
|
||||
@classmethod
|
||||
def of(cls, name: str) -> "PhotosIdentifierType":
|
||||
def of(cls, name: str) -> PhotosIdentifierType:
|
||||
"""Parse a PhotosIdentifierType by string value."""
|
||||
for enum in PhotosIdentifierType:
|
||||
if enum.value == name:
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""Config flow for the html5 component."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import binascii
|
||||
from typing import Any, cast
|
||||
|
||||
|
@ -42,7 +44,7 @@ class HTML5ConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
@callback
|
||||
def _async_create_html5_entry(
|
||||
self: "HTML5ConfigFlow", data: dict[str, str]
|
||||
self: HTML5ConfigFlow, data: dict[str, str]
|
||||
) -> tuple[dict[str, str], ConfigFlowResult | None]:
|
||||
"""Create an HTML5 entry."""
|
||||
errors = {}
|
||||
|
@ -68,7 +70,7 @@ class HTML5ConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
return errors, flow_result
|
||||
|
||||
async def async_step_user(
|
||||
self: "HTML5ConfigFlow", user_input: dict[str, Any] | None = None
|
||||
self: HTML5ConfigFlow, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by the user."""
|
||||
errors: dict[str, str] = {}
|
||||
|
@ -92,7 +94,7 @@ class HTML5ConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
)
|
||||
|
||||
async def async_step_import(
|
||||
self: "HTML5ConfigFlow", import_config: dict
|
||||
self: HTML5ConfigFlow, import_config: dict
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle config import from yaml."""
|
||||
_, flow_result = self._async_create_html5_entry(import_config)
|
||||
|
|
|
@ -19,8 +19,8 @@ _LOGGER = logging.getLogger(__name__)
|
|||
STORAGE_VERSION: Final = 1
|
||||
STORAGE_KEY: Final = f"{DOMAIN}/config_store.json"
|
||||
|
||||
KNXPlatformStoreModel = dict[str, dict[str, Any]] # unique_id: configuration
|
||||
KNXEntityStoreModel = dict[
|
||||
type KNXPlatformStoreModel = dict[str, dict[str, Any]] # unique_id: configuration
|
||||
type KNXEntityStoreModel = dict[
|
||||
str, KNXPlatformStoreModel
|
||||
] # platform: KNXPlatformStoreModel
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ if TYPE_CHECKING:
|
|||
from .entity import ZHAEntity
|
||||
from .update import ZHAFirmwareUpdateCoordinator
|
||||
|
||||
_LogFilterType = Filter | Callable[[LogRecord], bool]
|
||||
type _LogFilterType = Filter | Callable[[LogRecord], bool]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
"""Tests for the KNX integration."""
|
||||
|
||||
from collections.abc import Awaitable, Callable
|
||||
from collections.abc import Callable, Coroutine
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
KnxEntityGenerator = Callable[..., Awaitable[er.RegistryEntry]]
|
||||
type KnxEntityGenerator = Callable[..., Coroutine[Any, Any, er.RegistryEntry]]
|
||||
|
|
|
@ -310,7 +310,7 @@ def mock_smile_p1_2() -> Generator[MagicMock]:
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_smile_legacy_anna() -> Generator[None, MagicMock, None]:
|
||||
def mock_smile_legacy_anna() -> Generator[MagicMock]:
|
||||
"""Create a Mock legacy Anna environment for testing exceptions."""
|
||||
chosen_env = "legacy_anna"
|
||||
with patch(
|
||||
|
|
Loading…
Reference in New Issue