Skip to content

Commit fc21f92

Browse files
committed
pylint: fix pylint issues
Consider merging these comparisons with 'in' by *. Use a set instead if elements are hashable. (consider-using-in) Unnecessary parens after '=' keyword (superfluous-parens) Unused argument * (unused-argument) Signed-off-by: Tatiana Leon <Tatiana.Leon@digi.com>
1 parent 64c3a66 commit fc21f92

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

digi/xbee/devices.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,8 +2048,7 @@ def _before_send_method(func):
20482048
def dec_function(self, *args, **kwargs):
20492049
if not self._comm_iface.is_interface_open:
20502050
raise XBeeException("XBee device's communication interface closed.")
2051-
if (self._operating_mode != OperatingMode.API_MODE
2052-
and self._operating_mode != OperatingMode.ESCAPED_API_MODE):
2051+
if self._operating_mode not in (OperatingMode.API_MODE, OperatingMode.ESCAPED_API_MODE):
20532052
raise InvalidOperatingModeException(op_mode=self._operating_mode)
20542053
return func(self, *args, **kwargs)
20552054
return dec_function
@@ -2063,8 +2062,8 @@ def _after_send_method(func):
20632062
@wraps(func)
20642063
def dec_function(*args, **kwargs):
20652064
response = func(*args, **kwargs)
2066-
if (response.transmit_status != TransmitStatus.SUCCESS
2067-
and response.transmit_status != TransmitStatus.SELF_ADDRESSED):
2065+
if response.transmit_status not in (TransmitStatus.SUCCESS,
2066+
TransmitStatus.SELF_ADDRESSED):
20682067
raise TransmitException(transmit_status=response.transmit_status)
20692068
return response
20702069
return dec_function
@@ -7831,7 +7830,7 @@ def __get_signal_quality(wifi_version, signal_strength):
78317830
elif signal_strength >= -50:
78327831
quality = 100
78337832
else:
7834-
quality = (2 * (signal_strength + 100))
7833+
quality = 2 * (signal_strength + 100)
78357834
else:
78367835
quality = 2 * signal_strength
78377836

@@ -10419,14 +10418,14 @@ def __discover_next_node_neighbors(self, nodes_queue, active_processes, node_tim
1041910418

1042010419
return code
1042110420

10422-
def _check_not_discovered_nodes(self, devices_list, nodes_queue):
10421+
def _check_not_discovered_nodes(self, devices_list, _nodes_queue):
1042310422
"""
1042410423
Checks not discovered nodes in the current scan, and add them to the
1042510424
FIFO if necessary.
1042610425
1042710426
Args:
1042810427
devices_list (List): List of nodes to check.
10429-
nodes_queue (:class:`queue.Queue`): FIFO where the nodes to
10428+
_nodes_queue (:class:`queue.Queue`): FIFO where the nodes to
1043010429
discover their neighbors are stored.
1043110430
"""
1043210431
# Check for nodes in the network not discovered in this scan and ensure
@@ -10451,16 +10450,16 @@ def _check_not_discovered_nodes(self, devices_list, nodes_queue):
1045110450
self._log.debug(" - Reachable: %s (scan %d)",
1045210451
n_item._reachable, self.__scan_counter)
1045310452

10454-
def _discover_neighbors(self, requester, nodes_queue, active_processes, node_timeout):
10453+
def _discover_neighbors(self, _requester, _nodes_queue, _active_processes, _node_timeout):
1045510454
"""
1045610455
Starts the process to discover the neighbors of the given node.
1045710456
1045810457
Args:
10459-
requester(:class:`.AbstractXBeeDevice`): XBee to discover its neighbors.
10460-
nodes_queue (:class:`queue.Queue`): FIFO where the nodes to
10458+
_requester(:class:`.AbstractXBeeDevice`): XBee to discover its neighbors.
10459+
_nodes_queue (:class:`queue.Queue`): FIFO where the nodes to
1046110460
discover their neighbors are stored.
10462-
active_processes (List): List of active discovery processes.
10463-
node_timeout (Float): Timeout to discover neighbors (seconds).
10461+
_active_processes (List): List of active discovery processes.
10462+
_node_timeout (Float): Timeout to discover neighbors (seconds).
1046410463
1046510464
Returns:
1046610465
:class:`.NetworkDiscoveryStatus`: Resulting status of the process.
@@ -11126,8 +11125,8 @@ def __purge_network_connections(self, force=False):
1112611125
connections_to_remove = []
1112711126
with self.__conn_lock:
1112811127
for conn in self.__connections:
11129-
if (conn.scan_counter_a2b != self.__scan_counter
11130-
and conn.scan_counter_b2a != self.__scan_counter):
11128+
if self.__scan_counter not in (conn.scan_counter_a2b,
11129+
conn.scan_counter_b2a):
1113111130
conn.lq_a2b = LinkQuality.UNKNOWN
1113211131
conn.lq_b2a = LinkQuality.UNKNOWN
1113311132
connections_to_remove.append(conn)
@@ -11601,8 +11600,8 @@ def __process_discovered_neighbor_data(self, requester, routes, neighbor, nodes_
1160111600
connection = Connection(node, requester, lq_a2b=neighbor.lq,
1160211601
lq_b2a=LinkQuality.UNKNOWN, status_a2b=RouteStatus.ACTIVE,
1160311602
status_b2a=RouteStatus.UNKNOWN)
11604-
elif (neighbor.relationship == NeighborRelationship.CHILD
11605-
or neighbor.relationship == NeighborRelationship.UNDETERMINED):
11603+
elif neighbor.relationship in (NeighborRelationship.CHILD,
11604+
NeighborRelationship.UNDETERMINED):
1160611605
connection = Connection(requester, node, lq_a2b=neighbor.lq,
1160711606
lq_b2a=LinkQuality.UNKNOWN, status_a2b=RouteStatus.ACTIVE,
1160811607
status_b2a=RouteStatus.UNKNOWN)

digi/xbee/firmware.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5596,8 +5596,8 @@ def _finish_firmware_update(self):
55965596
and self._remote.get_protocol() == XBeeProtocol.DIGI_MESH
55975597
and self._target_fw_version <= 0x3004)
55985598
raw_802_error = (st_frame.transmit_status == TransmitStatus.NO_ACK
5599-
and self._remote.get_protocol() == XBeeProtocol.RAW_802_15_4
5600-
and self._target_fw_version <= 0x2002)
5599+
and self._remote.get_protocol() == XBeeProtocol.RAW_802_15_4
5600+
and self._target_fw_version <= 0x2002)
56015601
zb_addr_error = (st_frame.transmit_status == TransmitStatus.ADDRESS_NOT_FOUND
56025602
and self._remote.get_protocol() == XBeeProtocol.ZIGBEE
56035603
and self._target_fw_version <= 0x1009)
@@ -7305,7 +7305,7 @@ def update_remote_firmware(remote, xml_fw_file, firmware_file=None, bootloader_f
73057305
finally:
73067306
configurer.restore_after_update(
73077307
restore_settings=not update_process.check_protocol_changed_by_fw(orig_protocol))
7308-
finished = (remote._active_update_type == NodeUpdateType.FIRMWARE)
7308+
finished = remote._active_update_type == NodeUpdateType.FIRMWARE
73097309
if finished or msg != "Success":
73107310
update_process._notify_progress(msg, 100, finished=finished)
73117311

@@ -7370,7 +7370,7 @@ def update_remote_filesystem(remote, ota_fs_file, max_block_size=0, timeout=None
73707370
raise exc
73717371
finally:
73727372
configurer.restore_after_update()
7373-
finished = (remote._active_update_type == NodeUpdateType.FILESYSTEM)
7373+
finished = remote._active_update_type == NodeUpdateType.FILESYSTEM
73747374
if finished or msg != "Success":
73757375
update_process._notify_progress(msg, 100, finished=finished)
73767376

digi/xbee/packets/bluetooth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,19 @@ def __init__(self, start_command, scan_duration, scan_window,
107107
if scan_duration is None:
108108
raise ValueError("The scan duration cannot be None")
109109

110-
if not (self.INDEFINITE_SCAN_DURATION <= scan_duration <= self.__SCAN_DURATION_MAXIMUM):
110+
if not self.INDEFINITE_SCAN_DURATION <= scan_duration <= self.__SCAN_DURATION_MAXIMUM:
111111
raise ValueError(f"scan_duration must be between {self.INDEFINITE_SCAN_DURATION} and {self.__SCAN_DURATION_MAXIMUM}")
112112

113113
if scan_window is None:
114114
raise ValueError("The scan window cannot be None")
115115

116-
if not (self.__SCAN_WINDOW_MINIMUM <= scan_window <= self.__SCAN_WINDOW_MAXIMUM):
116+
if not self.__SCAN_WINDOW_MINIMUM <= scan_window <= self.__SCAN_WINDOW_MAXIMUM:
117117
raise ValueError(f"scan_window must be between {self.__SCAN_WINDOW_MINIMUM} and {self.__SCAN_WINDOW_MAXIMUM}")
118118

119119
if scan_interval is None:
120120
raise ValueError("The scan interval cannot be None")
121121

122-
if not (self.__SCAN_INTERVAL_MINIMUM <= scan_interval <= self.__SCAN_INTERVAL_MAXIMUM):
122+
if not self.__SCAN_INTERVAL_MINIMUM <= scan_interval <= self.__SCAN_INTERVAL_MAXIMUM:
123123
raise ValueError(f"scan_interval must be between {self.__SCAN_INTERVAL_MINIMUM} and {self.__SCAN_INTERVAL_MAXIMUM}")
124124

125125
if scan_interval < scan_window:

0 commit comments

Comments
 (0)