From 5864591150434cf8ace221cf3141a1797a031625 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 19 Sep 2024 13:28:09 +0200 Subject: [PATCH] Mark tag as entity component in pylint plugin (#126183) * Move tag base entity to separate module * Add tag to _ENTITY_COMPONENTS * Move Entity back in * Add tag to base platforms * Adjust core_files * Revert "Adjust core_files" This reverts commit 180c5034de5c4e80afeeb8149c6fa22395b215a4. * Revert "Add tag to base platforms" This reverts commit 381bcf12f0b52a5df665086862e715bbc7e90b79. --- homeassistant/components/tag/__init__.py | 2 +- pylint/plugins/hass_enforce_class_module.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/tag/__init__.py b/homeassistant/components/tag/__init__.py index 160408732c9..0462c5bec34 100644 --- a/homeassistant/components/tag/__init__.py +++ b/homeassistant/components/tag/__init__.py @@ -360,7 +360,7 @@ async def async_scan_tag( _LOGGER.debug("Tag: %s scanned by device: %s", tag_id, device_id) -class TagEntity(Entity): # pylint: disable=hass-enforce-class-module +class TagEntity(Entity): """Representation of a Tag entity.""" _unrecorded_attributes = frozenset({TAG_ID}) diff --git a/pylint/plugins/hass_enforce_class_module.py b/pylint/plugins/hass_enforce_class_module.py index 0fce0e13f63..c0b363bbddf 100644 --- a/pylint/plugins/hass_enforce_class_module.py +++ b/pylint/plugins/hass_enforce_class_module.py @@ -65,7 +65,8 @@ _MODULES: dict[str, set[str]] = { "WeatherEntityDescription", }, } -_PLATFORMS: set[str] = {platform.value for platform in Platform} +_ENTITY_COMPONENTS: set[str] = {platform.value for platform in Platform} +_ENTITY_COMPONENTS.add("tag") class HassEnforceClassModule(BaseChecker): @@ -92,7 +93,7 @@ class HassEnforceClassModule(BaseChecker): current_integration = parts[2] current_module = parts[3] if len(parts) > 3 else "" - if current_module != "entity" and current_integration not in _PLATFORMS: + if current_module != "entity" and current_integration not in _ENTITY_COMPONENTS: top_level_ancestors = list(node.ancestors(recurs=False)) for ancestor in top_level_ancestors: