From 62ea4b36cd6d3db2a72e22eb273d1f970eefd233 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Thu, 5 Oct 2023 20:08:22 +0200 Subject: [PATCH] Use loader.async_suggest_report_issue in number (#101388) --- homeassistant/components/number/__init__.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/number/__init__.py b/homeassistant/components/number/__init__.py index 4e0f5059c90..ad2b7d55ff8 100644 --- a/homeassistant/components/number/__init__.py +++ b/homeassistant/components/number/__init__.py @@ -5,7 +5,6 @@ from collections.abc import Callable from contextlib import suppress import dataclasses from datetime import timedelta -import inspect import logging from math import ceil, floor from typing import Any, Self, final @@ -14,7 +13,8 @@ import voluptuous as vol from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_MODE, CONF_UNIT_OF_MEASUREMENT, UnitOfTemperature -from homeassistant.core import HomeAssistant, ServiceCall, callback +from homeassistant.core import HomeAssistant, ServiceCall, async_get_hass, callback +from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.config_validation import ( PLATFORM_SCHEMA, PLATFORM_SCHEMA_BASE, @@ -23,6 +23,7 @@ from homeassistant.helpers.entity import Entity, EntityDescription from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.restore_state import ExtraStoredData, RestoreEntity from homeassistant.helpers.typing import ConfigType +from homeassistant.loader import async_suggest_report_issue from .const import ( # noqa: F401 ATTR_MAX, @@ -192,14 +193,10 @@ class NumberEntity(Entity): "value", ) ): - module = inspect.getmodule(cls) - if module and module.__file__ and "custom_components" in module.__file__: - report_issue = "report it to the custom integration author." - else: - report_issue = ( - "create a bug report at " - "https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue" - ) + hass: HomeAssistant | None = None + with suppress(HomeAssistantError): + hass = async_get_hass() + report_issue = async_suggest_report_issue(hass, module=cls.__module__) _LOGGER.warning( ( "%s::%s is overriding deprecated methods on an instance of "