Adjust issue_registry imports (#88878)
* Add issue_registry to RUFF extend aliases
* Adjust code accordingly
* Revert "Add issue_registry to RUFF extend aliases"
This reverts commit 4e73dd567b
.
* Revert changes to common.py
pull/88882/merge
parent
86acc4262e
commit
6ab0b2751d
|
@ -2,7 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import issue_registry
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
|
||||
from . import DOMAIN
|
||||
from .helpers import Observation
|
||||
|
@ -15,13 +15,13 @@ def raise_mirrored_entries(
|
|||
if len(observations) != 2:
|
||||
return
|
||||
if observations[0].is_mirror(observations[1]):
|
||||
issue_registry.async_create_issue(
|
||||
ir.async_create_issue(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"mirrored_entry/" + text,
|
||||
breaks_in_ha_version="2022.10.0",
|
||||
is_fixable=False,
|
||||
severity=issue_registry.IssueSeverity.WARNING,
|
||||
severity=ir.IssueSeverity.WARNING,
|
||||
translation_key="manual_migration",
|
||||
translation_placeholders={"entity": text},
|
||||
learn_more_url="https://github.com/home-assistant/core/pull/67631",
|
||||
|
@ -31,13 +31,13 @@ def raise_mirrored_entries(
|
|||
# Should deprecate in some future version (2022.10 at time of writing) & make prob_given_false required in schemas.
|
||||
def raise_no_prob_given_false(hass: HomeAssistant, text: str) -> None:
|
||||
"""In previous 2022.9 and earlier, prob_given_false was optional and had a default version."""
|
||||
issue_registry.async_create_issue(
|
||||
ir.async_create_issue(
|
||||
hass,
|
||||
DOMAIN,
|
||||
f"no_prob_given_false/{text}",
|
||||
breaks_in_ha_version="2022.10.0",
|
||||
is_fixable=False,
|
||||
severity=issue_registry.IssueSeverity.ERROR,
|
||||
severity=ir.IssueSeverity.ERROR,
|
||||
translation_key="no_prob_given_false",
|
||||
translation_placeholders={"entity": text},
|
||||
learn_more_url="https://github.com/home-assistant/core/pull/67631",
|
||||
|
|
|
@ -13,7 +13,7 @@ from homeassistant.components.sensor import (
|
|||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import issue_registry
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
@ -40,13 +40,13 @@ async def async_setup_platform(
|
|||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the Obihai sensor platform."""
|
||||
issue_registry.async_create_issue(
|
||||
ir.async_create_issue(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"manual_migration",
|
||||
breaks_in_ha_version="2023.6.0",
|
||||
is_fixable=False,
|
||||
severity=issue_registry.IssueSeverity.ERROR,
|
||||
severity=ir.IssueSeverity.ERROR,
|
||||
translation_key="manual_migration",
|
||||
)
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ from homeassistant.components.repairs import RepairsFlow
|
|||
from homeassistant.components.repairs.const import DOMAIN
|
||||
from homeassistant.const import __version__ as ha_version
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import issue_registry
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockUser, mock_platform
|
||||
|
@ -53,7 +53,7 @@ async def create_issues(hass, ws_client, issues=None):
|
|||
issues = DEFAULT_ISSUES
|
||||
|
||||
for issue in issues:
|
||||
issue_registry.async_create_issue(
|
||||
ir.async_create_issue(
|
||||
hass,
|
||||
issue["domain"],
|
||||
issue["issue_id"],
|
||||
|
@ -439,8 +439,8 @@ async def test_list_issues(
|
|||
"""Test we can list issues."""
|
||||
|
||||
# Add an inactive issue, this should not be exposed in the list
|
||||
hass_storage[issue_registry.STORAGE_KEY] = {
|
||||
"version": issue_registry.STORAGE_VERSION_MAJOR,
|
||||
hass_storage[ir.STORAGE_KEY] = {
|
||||
"version": ir.STORAGE_VERSION_MAJOR,
|
||||
"data": {
|
||||
"issues": [
|
||||
{
|
||||
|
@ -491,7 +491,7 @@ async def test_list_issues(
|
|||
]
|
||||
|
||||
for issue in issues:
|
||||
issue_registry.async_create_issue(
|
||||
ir.async_create_issue(
|
||||
hass,
|
||||
issue["domain"],
|
||||
issue["issue_id"],
|
||||
|
|
|
@ -4,7 +4,7 @@ from typing import Any
|
|||
import pytest
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import issue_registry
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
|
||||
from tests.common import async_capture_events, flush_store
|
||||
|
||||
|
@ -59,12 +59,10 @@ async def test_load_issues(hass: HomeAssistant) -> None:
|
|||
},
|
||||
]
|
||||
|
||||
events = async_capture_events(
|
||||
hass, issue_registry.EVENT_REPAIRS_ISSUE_REGISTRY_UPDATED
|
||||
)
|
||||
events = async_capture_events(hass, ir.EVENT_REPAIRS_ISSUE_REGISTRY_UPDATED)
|
||||
|
||||
for issue in issues:
|
||||
issue_registry.async_create_issue(
|
||||
ir.async_create_issue(
|
||||
hass,
|
||||
issue["domain"],
|
||||
issue["issue_id"],
|
||||
|
@ -101,9 +99,7 @@ async def test_load_issues(hass: HomeAssistant) -> None:
|
|||
"issue_id": "issue_4",
|
||||
}
|
||||
|
||||
issue_registry.async_ignore_issue(
|
||||
hass, issues[0]["domain"], issues[0]["issue_id"], True
|
||||
)
|
||||
ir.async_ignore_issue(hass, issues[0]["domain"], issues[0]["issue_id"], True)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(events) == 5
|
||||
|
@ -113,7 +109,7 @@ async def test_load_issues(hass: HomeAssistant) -> None:
|
|||
"issue_id": "issue_1",
|
||||
}
|
||||
|
||||
issue_registry.async_delete_issue(hass, issues[2]["domain"], issues[2]["issue_id"])
|
||||
ir.async_delete_issue(hass, issues[2]["domain"], issues[2]["issue_id"])
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(events) == 6
|
||||
|
@ -123,20 +119,20 @@ async def test_load_issues(hass: HomeAssistant) -> None:
|
|||
"issue_id": "issue_3",
|
||||
}
|
||||
|
||||
registry: issue_registry.IssueRegistry = hass.data[issue_registry.DATA_REGISTRY]
|
||||
registry: ir.IssueRegistry = hass.data[ir.DATA_REGISTRY]
|
||||
assert len(registry.issues) == 3
|
||||
issue1 = registry.async_get_issue("test", "issue_1")
|
||||
issue2 = registry.async_get_issue("test", "issue_2")
|
||||
issue4 = registry.async_get_issue("test", "issue_4")
|
||||
|
||||
registry2 = issue_registry.IssueRegistry(hass)
|
||||
registry2 = ir.IssueRegistry(hass)
|
||||
await flush_store(registry._store)
|
||||
await registry2.async_load()
|
||||
|
||||
assert list(registry.issues) == list(registry2.issues)
|
||||
|
||||
issue1_registry2 = registry2.async_get_issue("test", "issue_1")
|
||||
assert issue1_registry2 == issue_registry.IssueEntry(
|
||||
assert issue1_registry2 == ir.IssueEntry(
|
||||
active=False,
|
||||
breaks_in_ha_version=None,
|
||||
created=issue1.created,
|
||||
|
@ -153,7 +149,7 @@ async def test_load_issues(hass: HomeAssistant) -> None:
|
|||
translation_placeholders=None,
|
||||
)
|
||||
issue2_registry2 = registry2.async_get_issue("test", "issue_2")
|
||||
assert issue2_registry2 == issue_registry.IssueEntry(
|
||||
assert issue2_registry2 == ir.IssueEntry(
|
||||
active=False,
|
||||
breaks_in_ha_version=None,
|
||||
created=issue2.created,
|
||||
|
@ -178,9 +174,9 @@ async def test_loading_issues_from_storage(
|
|||
hass: HomeAssistant, hass_storage: dict[str, Any]
|
||||
) -> None:
|
||||
"""Test loading stored issues on start."""
|
||||
hass_storage[issue_registry.STORAGE_KEY] = {
|
||||
"version": issue_registry.STORAGE_VERSION_MAJOR,
|
||||
"minor_version": issue_registry.STORAGE_VERSION_MINOR,
|
||||
hass_storage[ir.STORAGE_KEY] = {
|
||||
"version": ir.STORAGE_VERSION_MAJOR,
|
||||
"minor_version": ir.STORAGE_VERSION_MINOR,
|
||||
"data": {
|
||||
"issues": [
|
||||
{
|
||||
|
@ -216,16 +212,16 @@ async def test_loading_issues_from_storage(
|
|||
},
|
||||
}
|
||||
|
||||
await issue_registry.async_load(hass)
|
||||
await ir.async_load(hass)
|
||||
|
||||
registry: issue_registry.IssueRegistry = hass.data[issue_registry.DATA_REGISTRY]
|
||||
registry: ir.IssueRegistry = hass.data[ir.DATA_REGISTRY]
|
||||
assert len(registry.issues) == 3
|
||||
|
||||
|
||||
@pytest.mark.parametrize("load_registries", [False])
|
||||
async def test_migration_1_1(hass: HomeAssistant, hass_storage: dict[str, Any]) -> None:
|
||||
"""Test migration from version 1.1."""
|
||||
hass_storage[issue_registry.STORAGE_KEY] = {
|
||||
hass_storage[ir.STORAGE_KEY] = {
|
||||
"version": 1,
|
||||
"minor_version": 1,
|
||||
"data": {
|
||||
|
@ -246,7 +242,7 @@ async def test_migration_1_1(hass: HomeAssistant, hass_storage: dict[str, Any])
|
|||
},
|
||||
}
|
||||
|
||||
await issue_registry.async_load(hass)
|
||||
await ir.async_load(hass)
|
||||
|
||||
registry: issue_registry.IssueRegistry = hass.data[issue_registry.DATA_REGISTRY]
|
||||
registry: ir.IssueRegistry = hass.data[ir.DATA_REGISTRY]
|
||||
assert len(registry.issues) == 2
|
||||
|
|
Loading…
Reference in New Issue