Skip to content

Commit 60ef5b7

Browse files
committed
Fix all "is True/False"
1 parent 4347dbb commit 60ef5b7

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

plugwise/messages/requests.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class NodeAddRequest(NodeRequest):
6060

6161
def __init__(self, mac, accept: bool):
6262
super().__init__(mac)
63-
accept_value = 1 if accept is True else 0
63+
accept_value = 1 if accept else 0
6464
self.args.append(Int(accept_value, length=2))
6565

6666
# This message has an exceptional format (MAC at end of message)
@@ -85,7 +85,7 @@ class NodeAllowJoiningRequest(NodeRequest):
8585
def __init__(self, accept: bool):
8686
super().__init__("")
8787
# TODO: Make sure that '01' means enable, and '00' disable joining
88-
val = 1 if accept is True else 0
88+
val = 1 if accept else 0
8989
self.args.append(Int(val, length=2))
9090

9191

@@ -183,7 +183,7 @@ class CircleSwitchRelayRequest(NodeRequest):
183183

184184
def __init__(self, mac, on):
185185
super().__init__(mac)
186-
val = 1 if on is True else 0
186+
val = 1 if on else 0
187187
self.args.append(Int(val, length=2))
188188

189189

@@ -286,7 +286,7 @@ class CircleEnableScheduleRequest(NodeRequest):
286286

287287
def __init__(self, mac, on):
288288
super().__init__(mac)
289-
val = 1 if on is True else 0
289+
val = 1 if on else 0
290290
self.args.append(Int(val, length=2))
291291
# the second parameter is always 0x01
292292
self.args.append(Int(1, length=2))
@@ -335,7 +335,7 @@ class NodeBroadcastGroupSwitchRequest(NodeRequest):
335335

336336
def __init__(self, group_mac, switch_state: bool):
337337
super().__init__(group_mac)
338-
val = 1 if switch_state is True else 0
338+
val = 1 if switch_state else 0
339339
self.args.append(Int(val, length=2))
340340

341341

@@ -382,7 +382,7 @@ def __init__(
382382
stay_active_val = Int(stay_active, length=2)
383383
sleep_for_val = Int(sleep_for, length=4)
384384
maintenance_interval_val = Int(maintenance_interval, length=4)
385-
val = 1 if sync_clock is True else 0
385+
val = 1 if sync_clock else 0
386386
clock_sync_val = Int(val, length=2)
387387
clock_interval_val = Int(clock_interval, length=4)
388388
self.args += [
@@ -479,7 +479,7 @@ def __init__(self, mac, reset_timer: int, sensitivity: int, light: bool):
479479
reset_timer_value = Int(reset_timer, length=2)
480480
# Sensitivity: HIGH(0x14), MEDIUM(0x1E), OFF(0xFF)
481481
sensitivity_value = Int(sensitivity, length=2)
482-
light_temp = 1 if light is True else 0
482+
light_temp = 1 if light else 0
483483
light_value = Int(light_temp, length=2)
484484
self.args += [
485485
sensitivity_value,
@@ -524,6 +524,6 @@ class CircleInitialRelaisStateRequest(NodeRequest):
524524

525525
def __init__(self, mac, configure: bool, relais_state: bool):
526526
super().__init__(mac)
527-
set_or_get = Int(1 if configure is True else 0, length=2)
528-
relais = Int(1 if relais_state is True else 0, length=2)
527+
set_or_get = Int(1 if configure else 0, length=2)
528+
relais = Int(1 if relais_state else 0, length=2)
529529
self.args += [set_or_get, relais]

plugwise/node.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class PlugwiseNode:
3232

3333
def __init__(self, mac, address, stick):
3434
mac = mac.upper()
35-
if validate_mac(mac) is False:
35+
if not validate_mac(mac):
3636
_LOGGER.debug(
3737
"MAC address is in unexpected format: %s",
3838
str(mac),
@@ -99,8 +99,8 @@ def get_available(self) -> bool:
9999

100100
def set_available(self, state, request_info=False):
101101
"""Set current network state of plugwise node."""
102-
if state is True:
103-
if self._available is False:
102+
if state:
103+
if not self._available:
104104
self._available = True
105105
_LOGGER.debug(
106106
"Mark node %s available",
@@ -110,7 +110,7 @@ def set_available(self, state, request_info=False):
110110
if request_info:
111111
self._request_info()
112112
else:
113-
if self._available is True:
113+
if self._available:
114114
self._available = False
115115
_LOGGER.debug(
116116
"Mark node %s unavailable",

plugwise/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def parse_data(self): # noqa: C901
6868
"""
6969
# TODO: flake8 indicates scan is too complex, level 35 indenting is indeed too complex
7070
_LOGGER.debug("Parse data: %s ", str(self._buffer))
71-
if self._parsing is False:
71+
if not self._parsing:
7272
self._parsing = True
7373

7474
# Lookup header of message in buffer

plugwise/stick.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def node(self, mac: str) -> PlugwiseNode:
322322

323323
def discover_node(self, mac: str, callback=None, force_discover=False) -> bool:
324324
""" Discovery of plugwise node """
325-
if validate_mac(mac) is True:
325+
if validate_mac(mac):
326326
if not self._plugwise_nodes.get(mac):
327327
if mac not in self._nodes_not_discovered.keys():
328328
self._nodes_not_discovered[mac] = (
@@ -458,7 +458,7 @@ def allow_join_requests(self, enable: bool, accept: bool):
458458

459459
def node_join(self, mac: str, callback=None) -> bool:
460460
"""Accept node to join Plugwise network by adding it in Circle+ memory"""
461-
if validate_mac(mac) is True:
461+
if validate_mac(mac):
462462
self.send(NodeAddRequest(bytes(mac, UTF8_DECODE), True), callback)
463463
return True
464464

@@ -467,7 +467,7 @@ def node_join(self, mac: str, callback=None) -> bool:
467467

468468
def node_unjoin(self, mac: str, callback=None) -> bool:
469469
"""Remove node from the Plugwise network by deleting it from the Circle+ memory"""
470-
if validate_mac(mac) is True:
470+
if validate_mac(mac):
471471
self.send(
472472
NodeRemoveRequest(bytes(self.circle_plus_mac, UTF8_DECODE), mac),
473473
callback,
@@ -1344,7 +1344,7 @@ def _watchdog_loop(self):
13441344
self._update_thread.daemon = True
13451345
self._update_thread.start()
13461346
# Circle+ discovery
1347-
if self._circle_plus_discovered is False:
1347+
if not self._circle_plus_discovered:
13481348
# First hour every once an hour
13491349
if self._circle_plus_retries < 60 or circle_plus_retry_counter > 60:
13501350
_LOGGER.info(

0 commit comments

Comments
 (0)