1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-08 17:49:37 +01:00

Deprecate yaml import in Shopping List (#169084)

This commit is contained in:
Michael
2026-04-27 14:04:11 +02:00
committed by GitHub
parent 3cc6cc9519
commit ed371bc644
2 changed files with 43 additions and 9 deletions
@@ -13,8 +13,13 @@ from homeassistant import config_entries
from homeassistant.components import http, websocket_api
from homeassistant.components.http.data_validator import RequestDataValidator
from homeassistant.const import ATTR_NAME, Platform
from homeassistant.core import HomeAssistant, ServiceCall, callback
from homeassistant.helpers import config_validation as cv
from homeassistant.core import (
DOMAIN as HOMEASSISTANT_DOMAIN,
HomeAssistant,
ServiceCall,
callback,
)
from homeassistant.helpers import config_validation as cv, issue_registry as ir
from homeassistant.helpers.typing import ConfigType
from .common import (
@@ -56,15 +61,31 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
if DOMAIN not in config:
return True
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}
)
)
hass.async_create_task(_async_setup(hass))
return True
async def _async_setup(hass: HomeAssistant) -> None:
await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}
)
ir.async_create_issue(
hass,
HOMEASSISTANT_DOMAIN,
f"deprecated_yaml_{DOMAIN}",
breaks_in_ha_version="2026.11.0",
is_fixable=False,
issue_domain=DOMAIN,
severity=ir.IssueSeverity.WARNING,
translation_key="deprecated_yaml",
translation_placeholders={
"domain": DOMAIN,
"integration_title": "Shopping List",
},
)
async def async_setup_entry(
hass: HomeAssistant, config_entry: ShoppingListConfigEntry
) -> bool:
+15 -2
View File
@@ -25,8 +25,9 @@ from homeassistant.components.websocket_api import (
TYPE_RESULT,
)
from homeassistant.const import ATTR_NAME
from homeassistant.core import HomeAssistant
from homeassistant.helpers import intent
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
from homeassistant.helpers import intent, issue_registry as ir
from homeassistant.setup import async_setup_component
from tests.common import async_capture_events
from tests.typing import ClientSessionGenerator, WebSocketGenerator
@@ -909,3 +910,15 @@ async def test_sort_list_service(
assert _get_shopping_data(hass).items[1][ATTR_NAME] == "ddd"
assert _get_shopping_data(hass).items[2][ATTR_NAME] == "aaa"
assert len(events) == 2
async def test_config_import_deprecation(
hass: HomeAssistant,
issue_registry: ir.IssueRegistry,
) -> None:
"""Test yaml config import is deprecated."""
await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
await hass.async_block_till_done(True)
assert (HOMEASSISTANT_DOMAIN, f"deprecated_yaml_{DOMAIN}") in issue_registry.issues