55import json
66import logging
77import re
8- from collections .abc import Iterator
9- from typing import Any , cast
8+ from typing import TYPE_CHECKING , Any , cast
109
1110from attr import define , field
1211
2423 UIWidget ,
2524 UpdateBoxStatus ,
2625)
27- from pyoverkiz .enums .command import OverkizCommand , OverkizCommandParam
2826from pyoverkiz .enums .protocol import Protocol
2927from pyoverkiz .enums .server import APIType , Server
3028from pyoverkiz .obfuscate import obfuscate_email , obfuscate_id , obfuscate_string
3129from pyoverkiz .types import DATA_TYPE_TO_PYTHON , StateType
3230
31+ if TYPE_CHECKING :
32+ from collections .abc import Iterator
33+
34+ from pyoverkiz .enums .command import OverkizCommand , OverkizCommandParam
35+
3336# pylint: disable=unused-argument, too-many-instance-attributes, too-many-locals
3437
3538# <protocol>://<gatewayId>/<deviceAddress>[#<subsystemId>]
@@ -527,7 +530,7 @@ def value_as_int(self) -> int | None:
527530 if self .type == DataType .NONE :
528531 return None
529532 if self .type == DataType .INTEGER :
530- return cast (int , self .value )
533+ return cast (" int" , self .value )
531534 raise TypeError (f"{ self .name } is not an integer" )
532535
533536 @property
@@ -536,9 +539,9 @@ def value_as_float(self) -> float | None:
536539 if self .type == DataType .NONE :
537540 return None
538541 if self .type == DataType .FLOAT :
539- return cast (float , self .value )
542+ return cast (" float" , self .value )
540543 if self .type == DataType .INTEGER :
541- return float (cast (int , self .value ))
544+ return float (cast (" int" , self .value ))
542545 raise TypeError (f"{ self .name } is not a float" )
543546
544547 @property
@@ -547,7 +550,7 @@ def value_as_bool(self) -> bool | None:
547550 if self .type == DataType .NONE :
548551 return None
549552 if self .type == DataType .BOOLEAN :
550- return cast (bool , self .value )
553+ return cast (" bool" , self .value )
551554 raise TypeError (f"{ self .name } is not a boolean" )
552555
553556 @property
@@ -556,7 +559,7 @@ def value_as_str(self) -> str | None:
556559 if self .type == DataType .NONE :
557560 return None
558561 if self .type == DataType .STRING :
559- return cast (str , self .value )
562+ return cast (" str" , self .value )
560563 raise TypeError (f"{ self .name } is not a string" )
561564
562565 @property
@@ -565,7 +568,7 @@ def value_as_dict(self) -> dict[str, Any] | None:
565568 if self .type == DataType .NONE :
566569 return None
567570 if self .type == DataType .JSON_OBJECT :
568- return cast (dict , self .value )
571+ return cast (" dict" , self .value )
569572 raise TypeError (f"{ self .name } is not a JSON object" )
570573
571574 @property
@@ -574,7 +577,7 @@ def value_as_list(self) -> list[Any] | None:
574577 if self .type == DataType .NONE :
575578 return None
576579 if self .type == DataType .JSON_ARRAY :
577- return cast (list , self .value )
580+ return cast (" list" , self .value )
578581 raise TypeError (f"{ self .name } is not an array" )
579582
580583
@@ -891,7 +894,7 @@ def __init__(
891894 if oid is None and id is None :
892895 raise ValueError ("Either 'oid' or 'id' must be provided" )
893896
894- self .id = cast (str , oid or id )
897+ self .id = cast (" str" , oid or id )
895898 self .creation_time = creation_time
896899 self .last_update_time = last_update_time
897900 self .label = (
@@ -904,7 +907,7 @@ def __init__(
904907 self .notification_text = notification_text
905908 self .notification_title = notification_title
906909 self .actions = [Action (** action ) for action in actions ]
907- self .oid = cast (str , oid or id )
910+ self .oid = cast (" str" , oid or id )
908911
909912
910913@define (init = False , kw_only = True )
0 commit comments