Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small typing improvements #126818

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion homeassistant/components/google_photos/media_source.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Media source for Google Photos."""

from __future__ import annotations

from dataclasses import dataclass
from enum import StrEnum
import logging
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 5 additions & 3 deletions homeassistant/components/html5/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Config flow for the html5 component."""

from __future__ import annotations

import binascii
from typing import Any, cast

Expand Down Expand Up @@ -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 = {}
Expand All @@ -68,7 +70,7 @@ def _async_create_html5_entry(
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] = {}
Expand All @@ -92,7 +94,7 @@ async def async_step_user(
)

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)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/knx/storage/config_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
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

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zha/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
from .entity import ZHAEntity
from .update import ZHAFirmwareUpdateCoordinator

_LogFilterType = Filter | Callable[[LogRecord], bool]
type _LogFilterType = Filter | Callable[[LogRecord], bool]

_LOGGER = logging.getLogger(__name__)

Expand Down
5 changes: 3 additions & 2 deletions tests/components/knx/__init__.py
Original file line number Diff line number Diff line change
@@ -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]]
2 changes: 1 addition & 1 deletion tests/components/plugwise/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading