mirror of
https://github.com/home-assistant/core.git
synced 2025-08-07 06:35:10 +02:00
Add async_entries_for_config_entry
This commit is contained in:
@@ -15,8 +15,12 @@ import voluptuous as vol
|
|||||||
from homeassistant.components import http, websocket_api
|
from homeassistant.components import http, websocket_api
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import config_validation as cv, integration_platform
|
from homeassistant.helpers import (
|
||||||
from homeassistant.helpers.device_registry import DeviceEntry, async_get
|
config_validation as cv,
|
||||||
|
device_registry as dr,
|
||||||
|
integration_platform,
|
||||||
|
)
|
||||||
|
from homeassistant.helpers.device_registry import DeviceEntry
|
||||||
from homeassistant.helpers.json import (
|
from homeassistant.helpers.json import (
|
||||||
ExtendedJSONEncoder,
|
ExtendedJSONEncoder,
|
||||||
find_paths_unserializable_data,
|
find_paths_unserializable_data,
|
||||||
@@ -280,7 +284,7 @@ class DownloadDiagnosticsView(http.HomeAssistantView):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Device diagnostics
|
# Device diagnostics
|
||||||
dev_reg = async_get(hass)
|
dev_reg = dr.async_get(hass)
|
||||||
if sub_id is None:
|
if sub_id is None:
|
||||||
return web.Response(status=HTTPStatus.BAD_REQUEST)
|
return web.Response(status=HTTPStatus.BAD_REQUEST)
|
||||||
|
|
||||||
|
@@ -397,7 +397,15 @@ _OBSOLETE_IMPORT: dict[str, list[ObsoleteImportMatch]] = {
|
|||||||
# Black list of imports that should be using the namespace
|
# Black list of imports that should be using the namespace
|
||||||
_FORCE_NAMESPACE_IMPORT: dict[tuple[str, str], str] = {
|
_FORCE_NAMESPACE_IMPORT: dict[tuple[str, str], str] = {
|
||||||
("homeassistant.helpers.area_registry", "async_get"): "ar.async_get",
|
("homeassistant.helpers.area_registry", "async_get"): "ar.async_get",
|
||||||
|
(
|
||||||
|
"homeassistant.helpers.device_registry",
|
||||||
|
"async_entries_for_config_entry",
|
||||||
|
): "dr.async_entries_for_config_entry",
|
||||||
("homeassistant.helpers.device_registry", "async_get"): "dr.async_get",
|
("homeassistant.helpers.device_registry", "async_get"): "dr.async_get",
|
||||||
|
(
|
||||||
|
"homeassistant.helpers.entity_registry",
|
||||||
|
"async_entries_for_config_entry",
|
||||||
|
): "er.async_entries_for_config_entry",
|
||||||
("homeassistant.helpers.entity_registry", "async_get"): "er.async_get",
|
("homeassistant.helpers.entity_registry", "async_get"): "er.async_get",
|
||||||
("homeassistant.helpers.issue_registry", "async_get"): "ir.async_get",
|
("homeassistant.helpers.issue_registry", "async_get"): "ir.async_get",
|
||||||
}
|
}
|
||||||
@@ -538,19 +546,16 @@ class HassImportsFormatChecker(BaseChecker):
|
|||||||
args=(import_match.string, obsolete_import.reason),
|
args=(import_match.string, obsolete_import.reason),
|
||||||
)
|
)
|
||||||
for name in node.names:
|
for name in node.names:
|
||||||
if self._has_invalid_namespace_import(node, node.modname, name[0]):
|
self._has_invalid_namespace_import(node, node.modname, name[0])
|
||||||
return
|
|
||||||
|
|
||||||
def _has_invalid_namespace_import(
|
def _has_invalid_namespace_import(
|
||||||
self, node: nodes.ImportFrom, module: str, name: str
|
self, node: nodes.ImportFrom, module: str, name: str
|
||||||
) -> bool:
|
) -> None:
|
||||||
for key, value in _FORCE_NAMESPACE_IMPORT.items():
|
for key, value in _FORCE_NAMESPACE_IMPORT.items():
|
||||||
if module == key[0] and name == key[1]:
|
if module == key[0] and name == key[1]:
|
||||||
self.add_message(
|
self.add_message(
|
||||||
"hass-helper-namespace-import", node=node, args=(name, value)
|
"hass-helper-namespace-import", node=node, args=(name, value)
|
||||||
)
|
)
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def register(linter: PyLinter) -> None:
|
def register(linter: PyLinter) -> None:
|
||||||
|
Reference in New Issue
Block a user