File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -20,12 +20,12 @@ def escape_illegal_xml_characters(xmldata: str) -> str:
2020 return re .sub (r"&([^a-zA-Z#])" , r"&\1" , xmldata )
2121
2222
23- def format_measure (measure : str , unit : str ) -> float | int | bool :
23+ def format_measure (measure : str , unit : str ) -> bool | float | int :
2424 """Format measure to correct type."""
2525 # TODO: handle with appropriate care 20220405
2626 # continuously reassigning the same value with different type isn't
2727 # to typings liking
28- result : int | float | bool = False
28+ result : bool | float | int = False
2929 try :
3030 result = int (measure )
3131 if unit == TEMP_CELSIUS :
@@ -52,10 +52,8 @@ def format_measure(measure: str, unit: str) -> float | int | bool:
5252 elif abs (float_measure ) >= 100 :
5353 result = int (round (float_measure ))
5454 except ValueError :
55- if measure in ["on" , "true" ]:
56- result = True
57- if measure in ["off" , "false" ]:
58- result = False
55+ result = measure in ["on" , "true" ]
56+
5957 return result
6058
6159
You can’t perform that action at this time.
0 commit comments