Fix ParamSpec Callable return types (#63701)

pull/63577/head
Marc Mueller 2022-01-09 06:03:18 +01:00 committed by GitHub
parent 37285194f8
commit 89859aad8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 13 deletions

View File

@ -2,7 +2,7 @@
from __future__ import annotations
import asyncio
from collections.abc import Awaitable, Callable, Sequence
from collections.abc import Awaitable, Callable, Coroutine, Sequence
import contextlib
from datetime import datetime, timedelta
import functools
@ -73,7 +73,7 @@ _P = ParamSpec("_P")
def catch_request_errors(
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."""
@functools.wraps(func)

View File

@ -1,9 +1,9 @@
"""Utilities for Evil Genius Labs."""
from __future__ import annotations
from collections.abc import Awaitable, Callable
from collections.abc import Awaitable, Callable, Coroutine
from functools import wraps
from typing import TypeVar
from typing import Any, TypeVar
from typing_extensions import Concatenate, ParamSpec
@ -16,7 +16,7 @@ _P = ParamSpec("_P")
def update_when_done(
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."""
@wraps(func)

View File

@ -1,8 +1,8 @@
"""Common code for tplink."""
from __future__ import annotations
from collections.abc import Awaitable, Callable
from typing import TypeVar
from collections.abc import Awaitable, Callable, Coroutine
from typing import Any, TypeVar
from kasa import SmartDevice
from typing_extensions import Concatenate, ParamSpec
@ -20,7 +20,7 @@ _P = ParamSpec("_P")
def async_refresh_after(
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."""
async def _async_wrap(self: _T, *args: _P.args, **kwargs: _P.kwargs) -> None:

View File

@ -1,7 +1,7 @@
"""Provide functionality to interact with the vlc telnet interface."""
from __future__ import annotations
from collections.abc import Awaitable, Callable
from collections.abc import Awaitable, Callable, Coroutine
from datetime import datetime
from functools import wraps
from typing import Any, TypeVar
@ -70,7 +70,7 @@ async def async_setup_entry(
def catch_vlc_errors(
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."""
@wraps(func)

View File

@ -2,7 +2,7 @@
from __future__ import annotations
import asyncio
from collections.abc import Awaitable, Callable
from collections.abc import Awaitable, Callable, Coroutine
from dataclasses import dataclass
from enum import Enum
from functools import partial
@ -53,12 +53,12 @@ def get_addon_manager(hass: HomeAssistant) -> AddonManager:
def api_error(
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."""
def handle_hassio_api_error(
func: Callable[_P, Awaitable[_R]]
) -> Callable[_P, Awaitable[_R]]:
) -> Callable[_P, Coroutine[Any, Any, _R]]:
"""Handle a HassioAPIError."""
async def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R: