Skip to content

Commit

Permalink
Add override decorators to sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed Jul 13, 2023
1 parent 52c7ad1 commit 558521e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion homeassistant/components/sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import sys
from typing import Any, Final, cast, final

from typing_extensions import Self
from typing_extensions import Self, override

from homeassistant.config_entries import ConfigEntry

Expand Down Expand Up @@ -268,6 +268,7 @@ def _default_to_device_class_name(self) -> bool:
return self.device_class not in (None, SensorDeviceClass.ENUM)

@property
@override
def device_class(self) -> SensorDeviceClass | None:
"""Return the class of this entity."""
if hasattr(self, "_attr_device_class"):
Expand Down Expand Up @@ -323,6 +324,7 @@ def last_reset(self) -> datetime | None:
return None

@property
@override
def capability_attributes(self) -> Mapping[str, Any] | None:
"""Return the capability attributes."""
if state_class := self.state_class:
Expand Down Expand Up @@ -368,6 +370,7 @@ def get_initial_entity_options(self) -> er.EntityOptionsType | None:

@final
@property
@override
def state_attributes(self) -> dict[str, Any] | None:
"""Return state attributes."""
if last_reset := self.last_reset:
Expand Down Expand Up @@ -445,6 +448,7 @@ def suggested_unit_of_measurement(self) -> str | None:

@final
@property
@override
def unit_of_measurement(self) -> str | None:
"""Return the unit of measurement of the entity, after unit conversion."""
# Highest priority, for registered entities: unit set by user,with fallback to
Expand Down Expand Up @@ -474,6 +478,7 @@ def unit_of_measurement(self) -> str | None:

@final
@property
@override
def state(self) -> Any:
"""Return the state of the sensor and perform unit conversions, if needed."""
native_unit_of_measurement = self.native_unit_of_measurement
Expand Down

0 comments on commit 558521e

Please sign in to comment.