From 76cbe7af734c89ae68421d88be16080404fd937a Mon Sep 17 00:00:00 2001 From: jbouwh Date: Fri, 22 Aug 2025 16:55:42 +0000 Subject: [PATCH] Remove extra check - ignore arg type --- homeassistant/components/number/__init__.py | 6 +++--- homeassistant/components/sensor/__init__.py | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/number/__init__.py b/homeassistant/components/number/__init__.py index 3c7f7d2ca52..2bf1bd13308 100644 --- a/homeassistant/components/number/__init__.py +++ b/homeassistant/components/number/__init__.py @@ -373,10 +373,10 @@ class NumberEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): @property def __native_unit_of_measurement_compat(self) -> str | None: """Process ambiguous units.""" - if (native_unit_of_measurement := self.native_unit_of_measurement) is None: - return None + native_unit_of_measurement = self.native_unit_of_measurement return AMBIGUOUS_UNITS.get( - native_unit_of_measurement, native_unit_of_measurement + native_unit_of_measurement, # type: ignore[arg-type] + native_unit_of_measurement, # type: ignore[arg-type] ) @property diff --git a/homeassistant/components/sensor/__init__.py b/homeassistant/components/sensor/__init__.py index acc0a476219..b3d03e756dd 100644 --- a/homeassistant/components/sensor/__init__.py +++ b/homeassistant/components/sensor/__init__.py @@ -474,11 +474,10 @@ class SensorEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): @property def __native_unit_of_measurement_compat(self) -> str | None: """Process ambiguous units.""" - if (native_unit_of_measurement := self.native_unit_of_measurement) is None: - return None + native_unit_of_measurement = self.native_unit_of_measurement return AMBIGUOUS_UNITS.get( - native_unit_of_measurement, - native_unit_of_measurement, + native_unit_of_measurement, # type: ignore[arg-type] + native_unit_of_measurement, # type: ignore[arg-type] ) @cached_property