Skip to content

Commit 9cc2a21

Browse files
committed
Improve
1 parent 2e04ce3 commit 9cc2a21

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

plugwise/util.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import ast
66
import datetime as dt
77
import re
8-
from typing import cast
8+
from typing import Any, cast
99

1010
from plugwise.constants import (
1111
ATTR_UNIT_OF_MEASUREMENT,
@@ -217,14 +217,15 @@ def format_measure(measure: str, unit: str) -> float | int:
217217
def get_vendor_name(module: etree, model_data: ModuleData) -> ModuleData:
218218
"""Helper-function for _get_model_data()."""
219219
if (vendor_name := module.find("vendor_name").text) is not None:
220-
model_data["vendor_name"] = parse_escapes(vendor_name)
220+
vendor_name = str(parse_escapes(vendor_name))
221+
model_data["vendor_name"] = vendor_name
221222
if "Plugwise" in vendor_name:
222223
model_data["vendor_name"] = vendor_name.split(" ", 1)[0]
223224

224225
return model_data
225226

226227

227-
def parse_escapes(text: str) -> str:
228+
def parse_escapes(text: str) -> Any:
228229
"""Helper-function for get_vendor_name()."""
229230
fixed_escapes = re.sub(r'(?<!\\)(\\\\)*("|\\$)', r"\\\1\2", text)
230231
return ast.literal_eval(f'"{fixed_escapes}"')

0 commit comments

Comments
 (0)