From 09e8ca7d0dda10f4d7d4b648b3f25faea64893f6 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 27 May 2024 09:56:50 +0000 Subject: [PATCH] Add async_entries_for_config_entry --- homeassistant/components/diagnostics/__init__.py | 10 +++++++--- pylint/plugins/hass_imports.py | 15 ++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/diagnostics/__init__.py b/homeassistant/components/diagnostics/__init__.py index 1c65b49fe0f..b23b7cef2bd 100644 --- a/homeassistant/components/diagnostics/__init__.py +++ b/homeassistant/components/diagnostics/__init__.py @@ -15,8 +15,12 @@ import voluptuous as vol from homeassistant.components import http, websocket_api from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant, callback -from homeassistant.helpers import config_validation as cv, integration_platform -from homeassistant.helpers.device_registry import DeviceEntry, async_get +from homeassistant.helpers import ( + config_validation as cv, + device_registry as dr, + integration_platform, +) +from homeassistant.helpers.device_registry import DeviceEntry from homeassistant.helpers.json import ( ExtendedJSONEncoder, find_paths_unserializable_data, @@ -280,7 +284,7 @@ class DownloadDiagnosticsView(http.HomeAssistantView): ) # Device diagnostics - dev_reg = async_get(hass) + dev_reg = dr.async_get(hass) if sub_id is None: return web.Response(status=HTTPStatus.BAD_REQUEST) diff --git a/pylint/plugins/hass_imports.py b/pylint/plugins/hass_imports.py index a2474bb78f9..40307df53f3 100644 --- a/pylint/plugins/hass_imports.py +++ b/pylint/plugins/hass_imports.py @@ -397,7 +397,15 @@ _OBSOLETE_IMPORT: dict[str, list[ObsoleteImportMatch]] = { # Black list of imports that should be using the namespace _FORCE_NAMESPACE_IMPORT: dict[tuple[str, str], str] = { ("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.entity_registry", + "async_entries_for_config_entry", + ): "er.async_entries_for_config_entry", ("homeassistant.helpers.entity_registry", "async_get"): "er.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), ) for name in node.names: - if self._has_invalid_namespace_import(node, node.modname, name[0]): - return + self._has_invalid_namespace_import(node, node.modname, name[0]) def _has_invalid_namespace_import( self, node: nodes.ImportFrom, module: str, name: str - ) -> bool: + ) -> None: for key, value in _FORCE_NAMESPACE_IMPORT.items(): if module == key[0] and name == key[1]: self.add_message( "hass-helper-namespace-import", node=node, args=(name, value) ) - return True - return False def register(linter: PyLinter) -> None: