Skip to content

Commit b848bf1

Browse files
committed
Util.py: add some typing hints
1 parent cbac4f7 commit b848bf1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

plugwise/util.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
44
Plugwise protocol helpers
55
"""
6+
from __future__ import annotations
7+
68
import binascii
79
import datetime
810
import re
@@ -34,7 +36,7 @@ def validate_mac(mac):
3436
return True
3537

3638

37-
def version_to_model(version):
39+
def version_to_model(version) -> str:
3840
"""Translate hardware_version to device type."""
3941
if version is None:
4042
return None
@@ -87,12 +89,12 @@ def int_to_uint(val, octals):
8789
return val
8890

8991

90-
def escape_illegal_xml_characters(xmldata):
92+
def escape_illegal_xml_characters(xmldata) -> str:
9193
"""Replace illegal &-characters."""
9294
return re.sub(r"&([^a-zA-Z#])", r"&\1", xmldata)
9395

9496

95-
def format_measure(measure, unit):
97+
def format_measure(measure, unit) -> float | int | bool:
9698
"""Format measure to correct type."""
9799
try:
98100
measure = int(measure)
@@ -121,7 +123,7 @@ def format_measure(measure, unit):
121123
return measure
122124

123125

124-
def determine_selected(available, selected, schemas):
126+
def determine_selected(available, selected, schemas) -> tuple[str, str]:
125127
"""Determine selected schema from available schemas."""
126128
for schema, active in schemas.items():
127129
if "None" in available:
@@ -132,7 +134,7 @@ def determine_selected(available, selected, schemas):
132134
return available, selected
133135

134136

135-
def in_between(now, start, end):
137+
def in_between(now, start, end) -> datetime.time:
136138
"""Determine timing for schedules."""
137139
if start <= end:
138140
return start <= now < end

0 commit comments

Comments
 (0)