Replace partial annotations (#114177)
This commit is contained in:
parent
6fafb9c9b4
commit
443bfee16d
3 changed files with 14 additions and 13 deletions
|
@ -30,7 +30,7 @@ from homeassistant.const import (
|
||||||
CONF_UNIQUE_ID,
|
CONF_UNIQUE_ID,
|
||||||
CONF_VALUE_TEMPLATE,
|
CONF_VALUE_TEMPLATE,
|
||||||
)
|
)
|
||||||
from homeassistant.core import CALLBACK_TYPE, Event, HomeAssistant, callback
|
from homeassistant.core import Event, HomeAssistant, callback
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import (
|
||||||
config_validation as cv,
|
config_validation as cv,
|
||||||
device_registry as dr,
|
device_registry as dr,
|
||||||
|
@ -278,8 +278,8 @@ def async_handle_schema_error(
|
||||||
async def _async_discover(
|
async def _async_discover(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
domain: str,
|
domain: str,
|
||||||
setup: partial[CALLBACK_TYPE] | None,
|
setup: Callable[[MQTTDiscoveryPayload], None] | None,
|
||||||
async_setup: partial[Coroutine[Any, Any, None]] | None,
|
async_setup: Callable[[MQTTDiscoveryPayload], Coroutine[Any, Any, None]] | None,
|
||||||
discovery_payload: MQTTDiscoveryPayload,
|
discovery_payload: MQTTDiscoveryPayload,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Discover and add an MQTT entity, automation or tag.
|
"""Discover and add an MQTT entity, automation or tag.
|
||||||
|
@ -314,10 +314,18 @@ async def _async_discover(
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
class _SetupNonEntityHelperCallbackProtocol(Protocol): # pragma: no cover
|
||||||
|
"""Callback protocol for async_setup in async_setup_non_entity_entry_helper."""
|
||||||
|
|
||||||
|
async def __call__(
|
||||||
|
self, config: ConfigType, discovery_data: DiscoveryInfoType
|
||||||
|
) -> None: ...
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_non_entity_entry_helper(
|
async def async_setup_non_entity_entry_helper(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
domain: str,
|
domain: str,
|
||||||
async_setup: partial[Coroutine[Any, Any, None]],
|
async_setup: _SetupNonEntityHelperCallbackProtocol,
|
||||||
discovery_schema: vol.Schema,
|
discovery_schema: vol.Schema,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up automation or tag creation dynamically through MQTT discovery."""
|
"""Set up automation or tag creation dynamically through MQTT discovery."""
|
||||||
|
@ -327,7 +335,7 @@ async def async_setup_non_entity_entry_helper(
|
||||||
discovery_payload: MQTTDiscoveryPayload,
|
discovery_payload: MQTTDiscoveryPayload,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up an MQTT entity, automation or tag from discovery."""
|
"""Set up an MQTT entity, automation or tag from discovery."""
|
||||||
config: DiscoveryInfoType = discovery_schema(discovery_payload)
|
config: ConfigType = discovery_schema(discovery_payload)
|
||||||
await async_setup(config, discovery_data=discovery_payload.discovery_data)
|
await async_setup(config, discovery_data=discovery_payload.discovery_data)
|
||||||
|
|
||||||
mqtt_data.reload_dispatchers.append(
|
mqtt_data.reload_dispatchers.append(
|
||||||
|
|
|
@ -100,7 +100,7 @@ def get_time_zone(time_zone_str: str) -> dt.tzinfo | None:
|
||||||
|
|
||||||
# We use a partial here since it is implemented in native code
|
# We use a partial here since it is implemented in native code
|
||||||
# and avoids the global lookup of UTC
|
# and avoids the global lookup of UTC
|
||||||
utcnow: partial[dt.datetime] = partial(dt.datetime.now, UTC)
|
utcnow = partial(dt.datetime.now, UTC)
|
||||||
utcnow.__doc__ = "Get now in UTC time."
|
utcnow.__doc__ = "Get now in UTC time."
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from functools import partial
|
|
||||||
import json
|
import json
|
||||||
import ssl
|
import ssl
|
||||||
from typing import Any, TypedDict
|
from typing import Any, TypedDict
|
||||||
|
@ -84,12 +83,6 @@ class _DebugInfo(TypedDict):
|
||||||
config: _DebugDeviceInfo
|
config: _DebugDeviceInfo
|
||||||
|
|
||||||
|
|
||||||
class RecordCallsPartial(partial[Any]):
|
|
||||||
"""Wrapper class for partial."""
|
|
||||||
|
|
||||||
__name__ = "RecordCallPartialTest"
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_storage(hass_storage: dict[str, Any]) -> None:
|
def mock_storage(hass_storage: dict[str, Any]) -> None:
|
||||||
"""Autouse hass_storage for the TestCase tests."""
|
"""Autouse hass_storage for the TestCase tests."""
|
||||||
|
|
Loading…
Add table
Reference in a new issue