Remove deprecated register_static_path method (#148303)

Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com>
This commit is contained in:
Manu 2025-07-07 15:27:19 +02:00 committed by GitHub
parent 799dc97d4a
commit c296e1f818
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 43 deletions

View File

@ -37,12 +37,7 @@ from homeassistant.const import (
)
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import (
config_validation as cv,
frame,
issue_registry as ir,
storage,
)
from homeassistant.helpers import config_validation as cv, issue_registry as ir, storage
from homeassistant.helpers.http import (
KEY_ALLOW_CONFIGURED_CORS,
KEY_AUTHENTICATED, # noqa: F401
@ -505,25 +500,6 @@ class HomeAssistantHTTP:
)
)
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_usage(
"calls hass.http.register_static_path which "
"does blocking I/O in the event loop, instead "
"call `await hass.http.async_register_static_paths("
f'[StaticPathConfig("{url_path}", "{path}", {cache_headers})])`',
exclude_integrations={"http"},
core_behavior=frame.ReportBehavior.ERROR,
core_integration_behavior=frame.ReportBehavior.ERROR,
custom_integration_behavior=frame.ReportBehavior.ERROR,
breaks_in_ha_version="2025.7",
)
configs = [StaticPathConfig(url_path, path, cache_headers)]
resources = self._make_static_resources(configs)
self._async_register_static_paths(configs, resources)
def _create_ssl_context(self) -> ssl.SSLContext | None:
context: ssl.SSLContext | None = None
assert self.ssl_certificate is not None

View File

@ -522,24 +522,6 @@ async def test_logging(
assert "GET /api/states/logging.entity" not in caplog.text
async def test_register_static_paths(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test registering a static path with old api."""
assert await async_setup_component(hass, "frontend", {})
path = str(Path(__file__).parent)
match_error = (
"Detected code that calls hass.http.register_static_path "
"which does blocking I/O in the event loop, instead call "
"`await hass.http.async_register_static_paths"
)
with pytest.raises(RuntimeError, match=match_error):
hass.http.register_static_path("/something", path)
async def test_ssl_issue_if_no_urls_configured(
hass: HomeAssistant,
tmp_path: Path,