Use loader.async_suggest_report_issue in number (#101388)

This commit is contained in:
Erik Montnemery 2023-10-05 20:08:22 +02:00 committed by GitHub
parent 659d437cac
commit 62ea4b36cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,6 @@ from collections.abc import Callable
from contextlib import suppress from contextlib import suppress
import dataclasses import dataclasses
from datetime import timedelta from datetime import timedelta
import inspect
import logging import logging
from math import ceil, floor from math import ceil, floor
from typing import Any, Self, final from typing import Any, Self, final
@ -14,7 +13,8 @@ import voluptuous as vol
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_MODE, CONF_UNIT_OF_MEASUREMENT, UnitOfTemperature 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 ( from homeassistant.helpers.config_validation import (
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE, PLATFORM_SCHEMA_BASE,
@ -23,6 +23,7 @@ from homeassistant.helpers.entity import Entity, EntityDescription
from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.restore_state import ExtraStoredData, RestoreEntity from homeassistant.helpers.restore_state import ExtraStoredData, RestoreEntity
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import async_suggest_report_issue
from .const import ( # noqa: F401 from .const import ( # noqa: F401
ATTR_MAX, ATTR_MAX,
@ -192,14 +193,10 @@ class NumberEntity(Entity):
"value", "value",
) )
): ):
module = inspect.getmodule(cls) hass: HomeAssistant | None = None
if module and module.__file__ and "custom_components" in module.__file__: with suppress(HomeAssistantError):
report_issue = "report it to the custom integration author." hass = async_get_hass()
else: report_issue = async_suggest_report_issue(hass, module=cls.__module__)
report_issue = (
"create a bug report at "
"https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue"
)
_LOGGER.warning( _LOGGER.warning(
( (
"%s::%s is overriding deprecated methods on an instance of " "%s::%s is overriding deprecated methods on an instance of "