Update typing 03 (#48015)
This commit is contained in:
parent
6fb2e63e49
commit
fabd73f08b
37 changed files with 417 additions and 379 deletions
|
@ -1,4 +1,6 @@
|
|||
"""Logging utilities."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from functools import partial, wraps
|
||||
import inspect
|
||||
|
@ -6,7 +8,7 @@ import logging
|
|||
import logging.handlers
|
||||
import queue
|
||||
import traceback
|
||||
from typing import Any, Awaitable, Callable, Coroutine, Union, cast, overload
|
||||
from typing import Any, Awaitable, Callable, Coroutine, cast, overload
|
||||
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
@ -115,7 +117,7 @@ def catch_log_exception(
|
|||
|
||||
def catch_log_exception(
|
||||
func: Callable[..., Any], format_err: Callable[..., Any], *args: Any
|
||||
) -> Union[Callable[..., None], Callable[..., Awaitable[None]]]:
|
||||
) -> Callable[..., None] | Callable[..., Awaitable[None]]:
|
||||
"""Decorate a callback to catch and log exceptions."""
|
||||
|
||||
# Check for partials to properly determine if coroutine function
|
||||
|
@ -123,7 +125,7 @@ def catch_log_exception(
|
|||
while isinstance(check_func, partial):
|
||||
check_func = check_func.func
|
||||
|
||||
wrapper_func: Union[Callable[..., None], Callable[..., Awaitable[None]]]
|
||||
wrapper_func: Callable[..., None] | Callable[..., Awaitable[None]]
|
||||
if asyncio.iscoroutinefunction(check_func):
|
||||
async_func = cast(Callable[..., Awaitable[None]], func)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue