Refactor frame.get_integration_frame (#101322)

This commit is contained in:
Erik Montnemery 2023-10-03 19:21:27 +02:00 committed by GitHub
parent 956098ae3a
commit ab2de18f8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 163 additions and 60 deletions

View file

@ -132,24 +132,24 @@ def deprecated_function(
def _print_deprecation_warning(obj: Any, replacement: str, description: str) -> None:
logger = logging.getLogger(obj.__module__)
try:
_, integration, path = get_integration_frame()
if path == "custom_components/":
integration_frame = get_integration_frame()
if integration_frame.custom_integration:
logger.warning(
(
"%s was called from %s, this is a deprecated %s. Use %s instead,"
" please report this to the maintainer of %s"
),
obj.__name__,
integration,
integration_frame.integration,
description,
replacement,
integration,
integration_frame.integration,
)
else:
logger.warning(
"%s was called from %s, this is a deprecated %s. Use %s instead",
obj.__name__,
integration,
integration_frame.integration,
description,
replacement,
)