mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add integration name to the deprecation warnings (#45901)
This commit is contained in:
parent
5615ab4c25
commit
90973f471f
@ -4,6 +4,8 @@ import inspect
|
||||
import logging
|
||||
from typing import Any, Callable, Dict, Optional
|
||||
|
||||
from ..helpers.frame import MissingIntegrationFrame, get_integration_frame
|
||||
|
||||
|
||||
def deprecated_substitute(substitute_name: str) -> Callable[..., Callable]:
|
||||
"""Help migrate properties to new names.
|
||||
@ -86,11 +88,29 @@ def deprecated_function(replacement: str) -> Callable[..., Callable]:
|
||||
def deprecated_func(*args: tuple, **kwargs: Dict[str, Any]) -> Any:
|
||||
"""Wrap for the original function."""
|
||||
logger = logging.getLogger(func.__module__)
|
||||
logger.warning(
|
||||
"%s is a deprecated function. Use %s instead",
|
||||
func.__name__,
|
||||
replacement,
|
||||
)
|
||||
try:
|
||||
_, integration, path = get_integration_frame()
|
||||
if path == "custom_components/":
|
||||
logger.warning(
|
||||
"%s was called from %s, this is a deprecated function. Use %s instead, please report this to the maintainer of %s",
|
||||
func.__name__,
|
||||
integration,
|
||||
replacement,
|
||||
integration,
|
||||
)
|
||||
else:
|
||||
logger.warning(
|
||||
"%s was called from %s, this is a deprecated function. Use %s instead",
|
||||
func.__name__,
|
||||
integration,
|
||||
replacement,
|
||||
)
|
||||
except MissingIntegrationFrame:
|
||||
logger.warning(
|
||||
"%s is a deprecated function. Use %s instead",
|
||||
func.__name__,
|
||||
replacement,
|
||||
)
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return deprecated_func
|
||||
|
Loading…
x
Reference in New Issue
Block a user