mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Fix ParamSpec Callable return types (#63701)
This commit is contained in:
parent
37285194f8
commit
89859aad8d
@ -2,7 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import Awaitable, Callable, Sequence
|
from collections.abc import Awaitable, Callable, Coroutine, Sequence
|
||||||
import contextlib
|
import contextlib
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import functools
|
import functools
|
||||||
@ -73,7 +73,7 @@ _P = ParamSpec("_P")
|
|||||||
|
|
||||||
def catch_request_errors(
|
def catch_request_errors(
|
||||||
func: Callable[Concatenate[_T, _P], Awaitable[_R]] # type: ignore[misc]
|
func: Callable[Concatenate[_T, _P], Awaitable[_R]] # type: ignore[misc]
|
||||||
) -> Callable[Concatenate[_T, _P], Awaitable[_R | None]]: # type: ignore[misc]
|
) -> Callable[Concatenate[_T, _P], Coroutine[Any, Any, _R | None]]: # type: ignore[misc]
|
||||||
"""Catch UpnpError errors."""
|
"""Catch UpnpError errors."""
|
||||||
|
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"""Utilities for Evil Genius Labs."""
|
"""Utilities for Evil Genius Labs."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Awaitable, Callable
|
from collections.abc import Awaitable, Callable, Coroutine
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from typing import TypeVar
|
from typing import Any, TypeVar
|
||||||
|
|
||||||
from typing_extensions import Concatenate, ParamSpec
|
from typing_extensions import Concatenate, ParamSpec
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ _P = ParamSpec("_P")
|
|||||||
|
|
||||||
def update_when_done(
|
def update_when_done(
|
||||||
func: Callable[Concatenate[_T, _P], Awaitable[_R]] # type: ignore[misc]
|
func: Callable[Concatenate[_T, _P], Awaitable[_R]] # type: ignore[misc]
|
||||||
) -> Callable[Concatenate[_T, _P], Awaitable[_R]]: # type: ignore[misc]
|
) -> Callable[Concatenate[_T, _P], Coroutine[Any, Any, _R]]: # type: ignore[misc]
|
||||||
"""Decorate function to trigger update when function is done."""
|
"""Decorate function to trigger update when function is done."""
|
||||||
|
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
"""Common code for tplink."""
|
"""Common code for tplink."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Awaitable, Callable
|
from collections.abc import Awaitable, Callable, Coroutine
|
||||||
from typing import TypeVar
|
from typing import Any, TypeVar
|
||||||
|
|
||||||
from kasa import SmartDevice
|
from kasa import SmartDevice
|
||||||
from typing_extensions import Concatenate, ParamSpec
|
from typing_extensions import Concatenate, ParamSpec
|
||||||
@ -20,7 +20,7 @@ _P = ParamSpec("_P")
|
|||||||
|
|
||||||
def async_refresh_after(
|
def async_refresh_after(
|
||||||
func: Callable[Concatenate[_T, _P], Awaitable[None]] # type: ignore[misc]
|
func: Callable[Concatenate[_T, _P], Awaitable[None]] # type: ignore[misc]
|
||||||
) -> Callable[Concatenate[_T, _P], Awaitable[None]]: # type: ignore[misc]
|
) -> Callable[Concatenate[_T, _P], Coroutine[Any, Any, None]]: # type: ignore[misc]
|
||||||
"""Define a wrapper to refresh after."""
|
"""Define a wrapper to refresh after."""
|
||||||
|
|
||||||
async def _async_wrap(self: _T, *args: _P.args, **kwargs: _P.kwargs) -> None:
|
async def _async_wrap(self: _T, *args: _P.args, **kwargs: _P.kwargs) -> None:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""Provide functionality to interact with the vlc telnet interface."""
|
"""Provide functionality to interact with the vlc telnet interface."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Awaitable, Callable
|
from collections.abc import Awaitable, Callable, Coroutine
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from typing import Any, TypeVar
|
from typing import Any, TypeVar
|
||||||
@ -70,7 +70,7 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
def catch_vlc_errors(
|
def catch_vlc_errors(
|
||||||
func: Callable[Concatenate[_T, _P], Awaitable[None]] # type: ignore[misc]
|
func: Callable[Concatenate[_T, _P], Awaitable[None]] # type: ignore[misc]
|
||||||
) -> Callable[Concatenate[_T, _P], Awaitable[None]]: # type: ignore[misc]
|
) -> Callable[Concatenate[_T, _P], Coroutine[Any, Any, None]]: # type: ignore[misc]
|
||||||
"""Catch VLC errors."""
|
"""Catch VLC errors."""
|
||||||
|
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import Awaitable, Callable
|
from collections.abc import Awaitable, Callable, Coroutine
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from functools import partial
|
from functools import partial
|
||||||
@ -53,12 +53,12 @@ def get_addon_manager(hass: HomeAssistant) -> AddonManager:
|
|||||||
|
|
||||||
def api_error(
|
def api_error(
|
||||||
error_message: str,
|
error_message: str,
|
||||||
) -> Callable[[Callable[_P, Awaitable[_R]]], Callable[_P, Awaitable[_R]]]:
|
) -> Callable[[Callable[_P, Awaitable[_R]]], Callable[_P, Coroutine[Any, Any, _R]]]:
|
||||||
"""Handle HassioAPIError and raise a specific AddonError."""
|
"""Handle HassioAPIError and raise a specific AddonError."""
|
||||||
|
|
||||||
def handle_hassio_api_error(
|
def handle_hassio_api_error(
|
||||||
func: Callable[_P, Awaitable[_R]]
|
func: Callable[_P, Awaitable[_R]]
|
||||||
) -> Callable[_P, Awaitable[_R]]:
|
) -> Callable[_P, Coroutine[Any, Any, _R]]:
|
||||||
"""Handle a HassioAPIError."""
|
"""Handle a HassioAPIError."""
|
||||||
|
|
||||||
async def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
|
async def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user