From 8dffc985337c3ff6ccbd32e2d271d519169258d6 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 27 May 2024 10:02:55 +0000 Subject: [PATCH] Improve --- pylint/plugins/hass_imports.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pylint/plugins/hass_imports.py b/pylint/plugins/hass_imports.py index 3c30367dca7..2b293c057a9 100644 --- a/pylint/plugins/hass_imports.py +++ b/pylint/plugins/hass_imports.py @@ -395,19 +395,17 @@ _OBSOLETE_IMPORT: dict[str, list[ObsoleteImportMatch]] = { } # Blacklist 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", +_FORCE_NAMESPACE_IMPORT: dict[tuple[str, str], set[str]] = { + ("homeassistant.helpers.area_registry", "ar"): {"async_get"}, + ("homeassistant.helpers.device_registry", "dr"): { + "async_get", "async_entries_for_config_entry", - ): "dr.async_entries_for_config_entry", - ("homeassistant.helpers.device_registry", "async_get"): "dr.async_get", - ( - "homeassistant.helpers.entity_registry", + }, + ("homeassistant.helpers.entity_registry", "er"): { + "async_get", "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", + }, + ("homeassistant.helpers.issue_registry", "ir"): {"async_get"}, } @@ -552,9 +550,11 @@ class HassImportsFormatChecker(BaseChecker): self, node: nodes.ImportFrom, module: str, name: str ) -> None: for key, value in _FORCE_NAMESPACE_IMPORT.items(): - if module == key[0] and name == key[1]: + if module == key[0] and name in value: self.add_message( - "hass-helper-namespace-import", node=node, args=(name, value) + "hass-helper-namespace-import", + node=node, + args=(name, f"{key[1]}.{name}"), )