From 3c363eb5ce02655778568dc4de1df6658e46e961 Mon Sep 17 00:00:00 2001
From: Erik Montnemery <erik@montnemery.com>
Date: Mon, 3 Mar 2025 10:17:13 +0100
Subject: [PATCH] Adjust type hints in update entity (#129387)

* Adjust type hints in update entity

* Update allowed return type of update_percentage

---------

Co-authored-by: Franck Nijhof <git@frenck.dev>
---
 homeassistant/components/update/__init__.py | 6 +++---
 pylint/plugins/hass_enforce_type_hints.py   | 6 +++++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/homeassistant/components/update/__init__.py b/homeassistant/components/update/__init__.py
index 0ff8c448197..47cc5aa369b 100644
--- a/homeassistant/components/update/__init__.py
+++ b/homeassistant/components/update/__init__.py
@@ -226,7 +226,7 @@ class UpdateEntity(
     _attr_installed_version: str | None = None
     _attr_device_class: UpdateDeviceClass | None
     _attr_display_precision: int
-    _attr_in_progress: bool | int = False
+    _attr_in_progress: bool = False
     _attr_latest_version: str | None = None
     _attr_release_summary: str | None = None
     _attr_release_url: str | None = None
@@ -295,7 +295,7 @@ class UpdateEntity(
         )
 
     @cached_property
-    def in_progress(self) -> bool | int | None:
+    def in_progress(self) -> bool | None:
         """Update installation progress.
 
         Needs UpdateEntityFeature.PROGRESS flag to be set for it to be used.
@@ -442,7 +442,7 @@ class UpdateEntity(
             in_progress = self.in_progress
             update_percentage = self.update_percentage if in_progress else None
             if type(in_progress) is not bool and isinstance(in_progress, int):
-                update_percentage = in_progress
+                update_percentage = in_progress  # type: ignore[unreachable]
                 in_progress = True
         else:
             in_progress = self.__in_progress
diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py
index a4590207294..ca7777da959 100644
--- a/pylint/plugins/hass_enforce_type_hints.py
+++ b/pylint/plugins/hass_enforce_type_hints.py
@@ -2568,7 +2568,7 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
                 ),
                 TypeHintMatch(
                     function_name="in_progress",
-                    return_type=["bool", "int", None],
+                    return_type=["bool", None],
                 ),
                 TypeHintMatch(
                     function_name="latest_version",
@@ -2590,6 +2590,10 @@ _INHERITANCE_MATCH: dict[str, list[ClassTypeHintMatch]] = {
                     function_name="title",
                     return_type=["str", None],
                 ),
+                TypeHintMatch(
+                    function_name="update_percentage",
+                    return_type=["int", "float", None],
+                ),
                 TypeHintMatch(
                     function_name="install",
                     arg_types={1: "str | None", 2: "bool"},
-- 
GitLab