Skip to content

Commit

Permalink
Exclude sensor_state_listener() from coverage test
Browse files Browse the repository at this point in the history
  • Loading branch information
Limych committed May 8, 2024
1 parent c358c04 commit 4f4908c
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions custom_components/iaquk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

import logging
from typing import Any, Dict, Final, List, Optional, Union
from typing import Any, Final

import voluptuous as vol

Expand Down Expand Up @@ -159,7 +159,7 @@ class Iaquk:
"""IAQ UK controller."""

def __init__(
self, hass, entity_id: str, name: str, sources: Dict[str, Union[str, List[str]]]
self, hass, entity_id: str, name: str, sources: dict[str, str | list[str]]
):
"""Initialize controller."""
self.hass = hass
Expand All @@ -176,6 +176,7 @@ def async_added_to_hass(self):
"""Register callbacks."""

# pylint: disable=unused-argument
# pragma: no cover
@callback
def sensor_state_listener(event: Event[EventStateChangedData]) -> None:
"""Handle device state changes."""
Expand Down Expand Up @@ -216,13 +217,13 @@ def name(self) -> str:
return self._name

@property
def iaq_index(self) -> Optional[int]:
def iaq_index(self) -> int | None:
"""Get IAQ index."""
return self._iaq_index

# pylint: disable=R1705
@property
def iaq_level(self) -> Optional[str]:
def iaq_level(self) -> str | None:
"""Get IAQ level."""
# Transform IAQ index to human readable text according
# to Indoor Air Quality UK: http://www.iaquk.org.uk/
Expand All @@ -239,7 +240,7 @@ def iaq_level(self) -> Optional[str]:
return LEVEL_EXCELLENT

@property
def state_attributes(self) -> Optional[Dict[str, Any]]:
def state_attributes(self) -> dict[str, Any] | None:
"""Return the state attributes."""
state_attr = {
ATTR_SOURCES_SET: len(self._sources),
Expand Down Expand Up @@ -288,7 +289,7 @@ def _has_state(state) -> bool:

def _get_number_state(
self, entity_id, entity_unit=None, source_type="", mweight=None
) -> Optional[float]:
) -> float | None:
"""Convert value to number."""
target_unit = None
if entity_unit is not None and not isinstance(entity_unit, dict):
Expand Down Expand Up @@ -352,7 +353,7 @@ def _get_number_state(
return value

@property
def _temperature_index(self) -> Optional[int]:
def _temperature_index(self) -> int | None:
"""Transform indoor temperature values to IAQ points."""
entity_id = self._sources.get(CONF_TEMPERATURE)
if entity_id is None:
Expand Down Expand Up @@ -386,7 +387,7 @@ def _temperature_index(self) -> Optional[int]:
return index

@property
def _humidity_index(self) -> Optional[int]:
def _humidity_index(self) -> int | None:
"""Transform indoor humidity values to IAQ points."""
entity_id = self._sources.get(CONF_HUMIDITY)
if entity_id is None:
Expand All @@ -408,7 +409,7 @@ def _humidity_index(self) -> Optional[int]:
return index

@property
def _co2_index(self) -> Optional[int]:
def _co2_index(self) -> int | None:
"""Transform indoor eCO2 values to IAQ points."""
entity_id = self._sources.get(CONF_CO2)
if entity_id is None:
Expand All @@ -432,7 +433,7 @@ def _co2_index(self) -> Optional[int]:
return index

@property
def _tvoc_index(self) -> Optional[int]:
def _tvoc_index(self) -> int | None:
"""Transform indoor tVOC values to IAQ points."""
entity_id = self._sources.get(CONF_TVOC)
if entity_id is None:
Expand All @@ -456,7 +457,7 @@ def _tvoc_index(self) -> Optional[int]:
return index

@property
def _voc_index_index(self) -> Optional[int]:
def _voc_index_index(self) -> int | None:
"""Transform indoor VOC index (0-500) values to IAQ points.
Especially for SGP40 and SGP41 gas sensors:
Expand Down Expand Up @@ -487,7 +488,7 @@ def _voc_index_index(self) -> Optional[int]:
return index

@property
def _pm_index(self) -> Optional[int]:
def _pm_index(self) -> int | None:
"""Transform indoor particulate matters values to IAQ points."""
entity_ids = self._sources.get(CONF_PM)
if entity_ids is None or entity_ids == []:
Expand Down Expand Up @@ -516,7 +517,7 @@ def _pm_index(self) -> Optional[int]:
return index

@property
def _no2_index(self) -> Optional[int]:
def _no2_index(self) -> int | None:
"""Transform indoor NO2 values to IAQ points."""
entity_id = self._sources.get(CONF_NO2)
if entity_id is None:
Expand All @@ -536,7 +537,7 @@ def _no2_index(self) -> Optional[int]:
return index

@property
def _co_index(self) -> Optional[int]:
def _co_index(self) -> int | None:
"""Transform indoor CO values to IAQ points."""
entity_id = self._sources.get(CONF_CO)
if entity_id is None:
Expand All @@ -556,7 +557,7 @@ def _co_index(self) -> Optional[int]:
return index

@property
def _hcho_index(self) -> Optional[int]:
def _hcho_index(self) -> int | None:
"""Transform indoor Formaldehyde (HCHO) values to IAQ points."""
entity_id = self._sources.get(CONF_HCHO)
if entity_id is None:
Expand Down

0 comments on commit 4f4908c

Please sign in to comment.