1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Update typing 02 (#48014)

This commit is contained in:
Marc Mueller
2021-03-17 18:34:19 +01:00
committed by GitHub
parent 86d3baa34e
commit 6fb2e63e49
47 changed files with 717 additions and 706 deletions

View File

@@ -1,8 +1,10 @@
"""Deprecation helpers for Home Assistant."""
from __future__ import annotations
import functools
import inspect
import logging
from typing import Any, Callable, Dict, Optional
from typing import Any, Callable
from ..helpers.frame import MissingIntegrationFrame, get_integration_frame
@@ -49,8 +51,8 @@ def deprecated_substitute(substitute_name: str) -> Callable[..., Callable]:
def get_deprecated(
config: Dict[str, Any], new_name: str, old_name: str, default: Optional[Any] = None
) -> Optional[Any]:
config: dict[str, Any], new_name: str, old_name: str, default: Any | None = None
) -> Any | None:
"""Allow an old config name to be deprecated with a replacement.
If the new config isn't found, but the old one is, the old value is used
@@ -85,7 +87,7 @@ def deprecated_function(replacement: str) -> Callable[..., Callable]:
"""Decorate function as deprecated."""
@functools.wraps(func)
def deprecated_func(*args: tuple, **kwargs: Dict[str, Any]) -> Any:
def deprecated_func(*args: tuple, **kwargs: dict[str, Any]) -> Any:
"""Wrap for the original function."""
logger = logging.getLogger(func.__module__)
try: