Skip to content

Commit

Permalink
Finish migration from report to report_usage (home-assistant#130412)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Nov 15, 2024
1 parent b57b22f commit 600f83d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
5 changes: 2 additions & 3 deletions homeassistant/components/http/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,15 +505,14 @@ def register_static_path(
self, url_path: str, path: str, cache_headers: bool = True
) -> None:
"""Register a folder or file to serve as a static path."""
frame.report(
frame.report_usage(
"calls hass.http.register_static_path which is deprecated because "
"it does blocking I/O in the event loop, instead "
"call `await hass.http.async_register_static_paths("
f'[StaticPathConfig("{url_path}", "{path}", {cache_headers})])`; '
"This function will be removed in 2025.7",
exclude_integrations={"http"},
error_if_core=False,
error_if_integration=False,
core_behavior=frame.ReportBehavior.LOG,
)
configs = [StaticPathConfig(url_path, path, cache_headers)]
resources = self._make_static_resources(configs)
Expand Down
16 changes: 6 additions & 10 deletions homeassistant/config_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
RANDOM_MICROSECOND_MIN,
async_call_later,
)
from .helpers.frame import ReportBehavior, report, report_usage
from .helpers.frame import ReportBehavior, report_usage
from .helpers.json import json_bytes, json_bytes_sorted, json_fragment
from .helpers.typing import UNDEFINED, ConfigType, DiscoveryInfoType, UndefinedType
from .loader import async_suggest_report_issue
Expand Down Expand Up @@ -1191,14 +1191,13 @@ class FlowCancelledError(Exception):

def _report_non_awaited_platform_forwards(entry: ConfigEntry, what: str) -> None:
"""Report non awaited platform forwards."""
report(
report_usage(
f"calls {what} for integration {entry.domain} with "
f"title: {entry.title} and entry_id: {entry.entry_id}, "
f"during setup without awaiting {what}, which can cause "
"the setup lock to be released before the setup is done. "
"This will stop working in Home Assistant 2025.1",
error_if_integration=False,
error_if_core=False,
core_behavior=ReportBehavior.LOG,
)


Expand Down Expand Up @@ -1266,10 +1265,8 @@ async def async_init(
SOURCE_RECONFIGURE,
} and "entry_id" not in context:
# Deprecated in 2024.12, should fail in 2025.12
report(
report_usage(
f"initialises a {source} flow without a link to the config entry",
error_if_integration=False,
error_if_core=True,
)

flow_id = ulid_util.ulid_now()
Expand Down Expand Up @@ -2321,14 +2318,13 @@ async def async_forward_entry_setup(
multiple platforms at once and is more efficient since it
does not require a separate import executor job for each platform.
"""
report(
report_usage(
"calls async_forward_entry_setup for "
f"integration, {entry.domain} with title: {entry.title} "
f"and entry_id: {entry.entry_id}, which is deprecated and "
"will stop working in Home Assistant 2025.6, "
"await async_forward_entry_setups instead",
error_if_core=False,
error_if_integration=False,
core_behavior=ReportBehavior.LOG,
)
if not entry.setup_lock.locked():
async with entry.setup_lock:
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/helpers/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,10 @@ def async_track_state_change(
Must be run within the event loop.
"""
frame.report(
frame.report_usage(
"calls `async_track_state_change` instead of `async_track_state_change_event`"
" which is deprecated and will be removed in Home Assistant 2025.5",
error_if_core=False,
core_behavior=frame.ReportBehavior.LOG,
)

if from_state is not None:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/util/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create_eager_task[_T](
# pylint: disable-next=import-outside-toplevel
from homeassistant.helpers import frame

frame.report("attempted to create an asyncio task from a thread")
frame.report_usage("attempted to create an asyncio task from a thread")
raise

return Task(coro, loop=loop, name=name, eager_start=True)
Expand Down

0 comments on commit 600f83d

Please sign in to comment.