Skip to content

Commit

Permalink
Fix typing errors for older Python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
klejejs committed Dec 29, 2022
1 parent 3ded7d4 commit 3ca2acc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion ThermiaOnlineAPI/api/ThermiaAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from requests import cookies
import json
import hashlib
from typing import Dict, Union

from ThermiaOnlineAPI.const import (
REG_GROUP_HOT_WATER,
Expand Down Expand Up @@ -281,7 +282,7 @@ def __get_switch_register_index_and_value_from_group_by_register_name(
"registerValue": int(register_value),
}

def get_group_hot_water(self, device: ThermiaHeatPump) -> dict[str, int | None]:
def get_group_hot_water(self, device: ThermiaHeatPump) -> Dict[str, Union[int, None]]:
register_data: list = self.__get_register_group(device.id, REG_GROUP_HOT_WATER)

hot_water_switch_data = (
Expand Down
18 changes: 9 additions & 9 deletions ThermiaOnlineAPI/model/HeatPump.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys
from ..utils.utils import pretty_print_except

from typing import TYPE_CHECKING, Dict
from typing import TYPE_CHECKING, Dict, Union

from ThermiaOnlineAPI.const import (
REG_BRINE_IN,
Expand Down Expand Up @@ -34,7 +34,7 @@
if TYPE_CHECKING:
from ..api.ThermiaAPI import ThermiaAPI

DEFAULT_REGISTER_INDEXES: Dict[str, int | None] = {
DEFAULT_REGISTER_INDEXES: Dict[str, Union[int, None]] = {
"temperature": None,
"operation_mode": None,
"hot_water_switch": None,
Expand All @@ -58,7 +58,7 @@ def __init__(self, device_data: dict, api_interface: "ThermiaAPI"):
self.__group_operational_status = None
self.__group_operational_time = None
self.__group_operational_operation = None
self.__group_hot_water: dict[str, int | None] = {
self.__group_hot_water: Dict[str, Union[int, None]] = {
"hot_water_switch": None,
"hot_water_boost_switch": None,
}
Expand Down Expand Up @@ -101,10 +101,10 @@ def get_register_indexes(self):
def set_register_index_operation_mode(self, register_index: int):
self.__register_indexes["operation_mode"] = register_index

def set_register_index_hot_water_switch(self, register_index: int | None):
def set_register_index_hot_water_switch(self, register_index: Union[int, None]):
self.__register_indexes["hot_water_switch"] = register_index

def set_register_index_hot_water_boost_switch(self, register_index: int | None):
def set_register_index_hot_water_boost_switch(self, register_index: Union[int, None]):
self.__register_indexes["hot_water_boost_switch"] = register_index

def set_temperature(self, temperature: int):
Expand Down Expand Up @@ -304,7 +304,7 @@ def __set_historical_data_registers(self):

self.__historical_data_registers_map = data_map

def __get_register_from_operational_status(self, register_name: str) -> dict | None:
def __get_register_from_operational_status(self, register_name: str) -> Union[dict, None]:
data = [
d
for d in self.__group_operational_status or []
Expand Down Expand Up @@ -337,7 +337,7 @@ def __get_value_by_key_and_register_name_from_operational_status(

return None

def __get_all_operational_statuses_from_operational_status(self) -> ChainMap | None:
def __get_all_operational_statuses_from_operational_status(self) -> Union[ChainMap, None]:
data = self.__get_register_from_operational_status(REG_OPERATIONAL_STATUS_PRIO1)

if data is None:
Expand Down Expand Up @@ -680,11 +680,11 @@ def is_hot_water_switch_available(self):
return self.__group_hot_water is not None

@property
def hot_water_switch_state(self) -> int | None:
def hot_water_switch_state(self) -> Union[int, None]:
return self.__group_hot_water["hot_water_switch"]

@property
def hot_water_boost_switch_state(self) -> int | None:
def hot_water_boost_switch_state(self) -> Union[int, None]:
return self.__group_hot_water["hot_water_boost_switch"]

###########################################################################
Expand Down

0 comments on commit 3ca2acc

Please sign in to comment.