Use report_usage in helpers (#130365)
This commit is contained in:
parent
22aed92461
commit
7045b776b6
5 changed files with 19 additions and 23 deletions
|
@ -719,14 +719,14 @@ def template(value: Any | None) -> template_helper.Template:
|
|||
raise vol.Invalid("template value should be a string")
|
||||
if not (hass := _async_get_hass_or_none()):
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from .frame import report
|
||||
from .frame import ReportBehavior, report_usage
|
||||
|
||||
report(
|
||||
report_usage(
|
||||
(
|
||||
"validates schema outside the event loop, "
|
||||
"which will stop working in HA Core 2025.10"
|
||||
),
|
||||
error_if_core=False,
|
||||
core_behavior=ReportBehavior.LOG,
|
||||
)
|
||||
|
||||
template_value = template_helper.Template(str(value), hass)
|
||||
|
@ -748,14 +748,14 @@ def dynamic_template(value: Any | None) -> template_helper.Template:
|
|||
raise vol.Invalid("template value does not contain a dynamic template")
|
||||
if not (hass := _async_get_hass_or_none()):
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from .frame import report
|
||||
from .frame import ReportBehavior, report_usage
|
||||
|
||||
report(
|
||||
report_usage(
|
||||
(
|
||||
"validates schema outside the event loop, "
|
||||
"which will stop working in HA Core 2025.10"
|
||||
),
|
||||
error_if_core=False,
|
||||
core_behavior=ReportBehavior.LOG,
|
||||
)
|
||||
|
||||
template_value = template_helper.Template(str(value), hass)
|
||||
|
|
|
@ -997,14 +997,14 @@ class TrackTemplateResultInfo:
|
|||
continue
|
||||
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from .frame import report
|
||||
from .frame import ReportBehavior, report_usage
|
||||
|
||||
report(
|
||||
report_usage(
|
||||
(
|
||||
"calls async_track_template_result with template without hass, "
|
||||
"which will stop working in HA Core 2025.10"
|
||||
),
|
||||
error_if_core=False,
|
||||
core_behavior=ReportBehavior.LOG,
|
||||
)
|
||||
track_template_.template.hass = hass
|
||||
|
||||
|
|
|
@ -1277,14 +1277,14 @@ def async_register_entity_service(
|
|||
schema = cv.make_entity_service_schema(schema)
|
||||
elif not cv.is_entity_service_schema(schema):
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from .frame import report
|
||||
from .frame import ReportBehavior, report_usage
|
||||
|
||||
report(
|
||||
report_usage(
|
||||
(
|
||||
"registers an entity service with a non entity service schema "
|
||||
"which will stop working in HA Core 2025.9"
|
||||
),
|
||||
error_if_core=False,
|
||||
core_behavior=ReportBehavior.LOG,
|
||||
)
|
||||
|
||||
service_func: str | HassJob[..., Any]
|
||||
|
|
|
@ -515,18 +515,18 @@ class Template:
|
|||
will be non optional in Home Assistant Core 2025.10.
|
||||
"""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from .frame import report
|
||||
from .frame import ReportBehavior, report_usage
|
||||
|
||||
if not isinstance(template, str):
|
||||
raise TypeError("Expected template to be a string")
|
||||
|
||||
if not hass:
|
||||
report(
|
||||
report_usage(
|
||||
(
|
||||
"creates a template object without passing hass, "
|
||||
"which will stop working in HA Core 2025.10"
|
||||
),
|
||||
error_if_core=False,
|
||||
core_behavior=ReportBehavior.LOG,
|
||||
)
|
||||
|
||||
self.template: str = template.strip()
|
||||
|
|
|
@ -29,7 +29,7 @@ from homeassistant.util.dt import utcnow
|
|||
|
||||
from . import entity, event
|
||||
from .debounce import Debouncer
|
||||
from .frame import report
|
||||
from .frame import report_usage
|
||||
from .typing import UNDEFINED, UndefinedType
|
||||
|
||||
REQUEST_REFRESH_DEFAULT_COOLDOWN = 10
|
||||
|
@ -286,24 +286,20 @@ class DataUpdateCoordinator(BaseDataUpdateCoordinatorProtocol, Generic[_DataT]):
|
|||
to ensure that multiple retries do not cause log spam.
|
||||
"""
|
||||
if self.config_entry is None:
|
||||
report(
|
||||
report_usage(
|
||||
"uses `async_config_entry_first_refresh`, which is only supported "
|
||||
"for coordinators with a config entry and will stop working in "
|
||||
"Home Assistant 2025.11",
|
||||
error_if_core=True,
|
||||
error_if_integration=False,
|
||||
"Home Assistant 2025.11"
|
||||
)
|
||||
elif (
|
||||
self.config_entry.state
|
||||
is not config_entries.ConfigEntryState.SETUP_IN_PROGRESS
|
||||
):
|
||||
report(
|
||||
report_usage(
|
||||
"uses `async_config_entry_first_refresh`, which is only supported "
|
||||
f"when entry state is {config_entries.ConfigEntryState.SETUP_IN_PROGRESS}, "
|
||||
f"but it is in state {self.config_entry.state}, "
|
||||
"This will stop working in Home Assistant 2025.11",
|
||||
error_if_core=True,
|
||||
error_if_integration=False,
|
||||
)
|
||||
if await self.__wrap_async_setup():
|
||||
await self._async_refresh(
|
||||
|
|
Loading…
Add table
Reference in a new issue