34
34
class Item :
35
35
"""Base item class."""
36
36
37
- types : typing .Sequence [typing . Type [openhab .command_types .CommandType ]] = []
38
- state_types : typing .Sequence [typing . Type [openhab .command_types .CommandType ]] = []
39
- command_event_types : typing .Sequence [typing . Type [openhab .command_types .CommandType ]] = []
40
- state_event_types : typing .Sequence [typing . Type [openhab .command_types .CommandType ]] = []
41
- state_changed_event_types : typing .Sequence [typing . Type [openhab .command_types .CommandType ]] = []
37
+ types : typing .Sequence [type [openhab .command_types .CommandType ]] = []
38
+ state_types : typing .Sequence [type [openhab .command_types .CommandType ]] = []
39
+ command_event_types : typing .Sequence [type [openhab .command_types .CommandType ]] = []
40
+ state_event_types : typing .Sequence [type [openhab .command_types .CommandType ]] = []
41
+ state_changed_event_types : typing .Sequence [type [openhab .command_types .CommandType ]] = []
42
42
43
43
TYPENAME = 'unknown'
44
44
@@ -144,7 +144,7 @@ def unit_of_measure(self) -> str:
144
144
return self ._unitOfMeasure
145
145
146
146
@property
147
- def members (self ) -> typing . Dict [str , typing .Any ]:
147
+ def members (self ) -> dict [str , typing .Any ]:
148
148
"""If item is a type of Group, it will return all member items for this group.
149
149
150
150
For none group item empty dictionary will be returned.
@@ -155,7 +155,7 @@ def members(self) -> typing.Dict[str, typing.Any]:
155
155
"""
156
156
return self ._members
157
157
158
- def _validate_value (self , value : typing .Union [str , typing . Type [openhab .command_types .CommandType ]]) -> None :
158
+ def _validate_value (self , value : typing .Union [str , type [openhab .command_types .CommandType ]]) -> None :
159
159
"""Private method for verifying the new value before modifying the state of the item."""
160
160
if self .type_ == 'String' :
161
161
if not isinstance (value , (str , bytes )):
@@ -176,7 +176,7 @@ def _validate_value(self, value: typing.Union[str, typing.Type[openhab.command_t
176
176
else :
177
177
raise ValueError
178
178
179
- def _parse_rest (self , value : str ) -> typing . Tuple [str , str ]:
179
+ def _parse_rest (self , value : str ) -> tuple [str , str ]:
180
180
"""Parse a REST result into a native object."""
181
181
return value , ''
182
182
@@ -289,7 +289,7 @@ def persistence(
289
289
page : int = 0 ,
290
290
page_length : int = 0 ,
291
291
boundary : bool = False ,
292
- ) -> typing .Iterator [typing . Dict [str , typing .Union [str , int ]]]:
292
+ ) -> typing .Iterator [dict [str , typing .Union [str , int ]]]:
293
293
"""Method for fetching persistence data for a given item.
294
294
295
295
Args:
@@ -321,8 +321,8 @@ class GroupItem(Item):
321
321
"""String item type."""
322
322
323
323
TYPENAME = 'Group'
324
- types : typing . List [ typing . Type [openhab .command_types .CommandType ]] = []
325
- state_types : typing . List [ typing . Type [openhab .command_types .CommandType ]] = []
324
+ types : list [ type [openhab .command_types .CommandType ]] = []
325
+ state_types : list [ type [openhab .command_types .CommandType ]] = []
326
326
327
327
328
328
class StringItem (Item ):
@@ -382,7 +382,7 @@ def __ne__(self, other: object) -> bool:
382
382
383
383
return not self .__eq__ (other )
384
384
385
- def _parse_rest (self , value : str ) -> typing . Tuple [datetime .datetime , str ]: # type: ignore[override]
385
+ def _parse_rest (self , value : str ) -> tuple [datetime .datetime , str ]: # type: ignore[override]
386
386
"""Parse a REST result into a native object.
387
387
388
388
Args:
@@ -470,7 +470,7 @@ class NumberItem(Item):
470
470
types = [openhab .command_types .DecimalType ]
471
471
state_types = types
472
472
473
- def _parse_rest (self , value : str ) -> typing . Tuple [typing .Union [float , None ], str ]: # type: ignore[override]
473
+ def _parse_rest (self , value : str ) -> tuple [typing .Union [float , None ], str ]: # type: ignore[override]
474
474
"""Parse a REST result into a native object.
475
475
476
476
Args:
@@ -499,7 +499,7 @@ def _parse_rest(self, value: str) -> typing.Tuple[typing.Union[float, None], str
499
499
500
500
raise ValueError (f'{ self .__class__ } : unable to parse value "{ value } "' )
501
501
502
- def _rest_format (self , value : typing .Union [float , typing . Tuple [float , str ], str ]) -> typing .Union [str , bytes ]:
502
+ def _rest_format (self , value : typing .Union [float , tuple [float , str ], str ]) -> typing .Union [str , bytes ]:
503
503
"""Format a value before submitting to openHAB.
504
504
505
505
Args:
@@ -545,7 +545,7 @@ class DimmerItem(Item):
545
545
types = [openhab .command_types .OnOffType , openhab .command_types .PercentType , openhab .command_types .IncreaseDecreaseType ]
546
546
state_types = [openhab .command_types .PercentType ]
547
547
548
- def _parse_rest (self , value : str ) -> typing . Tuple [float , str ]: # type: ignore[override]
548
+ def _parse_rest (self , value : str ) -> tuple [float , str ]: # type: ignore[override]
549
549
"""Parse a REST result into a native object.
550
550
551
551
Args:
@@ -595,7 +595,7 @@ class ColorItem(DimmerItem):
595
595
types = [openhab .command_types .OnOffType , openhab .command_types .PercentType , openhab .command_types .IncreaseDecreaseType , openhab .command_types .ColorType ]
596
596
state_types = [openhab .command_types .ColorType ]
597
597
598
- def _parse_rest (self , value : str ) -> typing . Tuple [typing .Optional [typing . Tuple [float , float , float ]], str ]: # type: ignore[override]
598
+ def _parse_rest (self , value : str ) -> tuple [typing .Optional [tuple [float , float , float ]], str ]: # type: ignore[override]
599
599
"""Parse a REST result into a native object.
600
600
601
601
Args:
@@ -608,7 +608,7 @@ def _parse_rest(self, value: str) -> typing.Tuple[typing.Optional[typing.Tuple[f
608
608
result = openhab .command_types .ColorType .parse (value )
609
609
return result , ''
610
610
611
- def _rest_format (self , value : typing .Union [typing . Tuple [int , int , float ], str , int ]) -> str :
611
+ def _rest_format (self , value : typing .Union [tuple [int , int , float ], str , int ]) -> str :
612
612
"""Format a value before submitting to openHAB.
613
613
614
614
Args:
@@ -634,7 +634,7 @@ class RollershutterItem(Item):
634
634
types = [openhab .command_types .UpDownType , openhab .command_types .PercentType , openhab .command_types .StopMoveType ]
635
635
state_types = [openhab .command_types .PercentType ]
636
636
637
- def _parse_rest (self , value : str ) -> typing . Tuple [int , str ]: # type: ignore[override]
637
+ def _parse_rest (self , value : str ) -> tuple [int , str ]: # type: ignore[override]
638
638
"""Parse a REST result into a native object.
639
639
640
640
Args:
@@ -680,7 +680,7 @@ class LocationItem(Item):
680
680
types = [openhab .command_types .PointType ]
681
681
state_types = [openhab .command_types .PointType ]
682
682
683
- def _parse_rest (self , value : str ) -> typing . Tuple [typing .Optional [typing . Tuple [float , float , float ]], str ]: # type: ignore[override]
683
+ def _parse_rest (self , value : str ) -> tuple [typing .Optional [tuple [float , float , float ]], str ]: # type: ignore[override]
684
684
"""Parse a REST result into a native object.
685
685
686
686
Args:
@@ -692,7 +692,7 @@ def _parse_rest(self, value: str) -> typing.Tuple[typing.Optional[typing.Tuple[f
692
692
"""
693
693
return openhab .command_types .PointType .parse (value ), ''
694
694
695
- def _rest_format (self , value : typing .Union [typing . Tuple [float , float , float ], str ]) -> str :
695
+ def _rest_format (self , value : typing .Union [tuple [float , float , float ], str ]) -> str :
696
696
"""Format a value before submitting to openHAB.
697
697
698
698
Args:
0 commit comments