From 9d76d1e3df9a982095095ddb7dddc546f9e3d344 Mon Sep 17 00:00:00 2001 From: Pierre Kancir Date: Thu, 31 Aug 2023 23:46:25 +0200 Subject: [PATCH] Tools: Test for membership should be `not in` --- Tools/LogAnalyzer/DataflashLog.py | 2 +- Tools/Replay/check_replay.py | 2 +- Tools/ardupilotwaf/boards.py | 2 +- Tools/ardupilotwaf/chibios.py | 4 ++-- Tools/ardupilotwaf/mavgen.py | 2 +- Tools/ardupilotwaf/toolchain.py | 2 +- Tools/autotest/arduplane.py | 4 ++-- Tools/scripts/CAN/fix2_gap.py | 2 +- Tools/scripts/configure_all.py | 2 +- Tools/scripts/param_unpack.py | 2 +- Tools/scripts/tempcal_IMU.py | 6 +++--- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Tools/LogAnalyzer/DataflashLog.py b/Tools/LogAnalyzer/DataflashLog.py index 37582ef2bd..a96cca589c 100644 --- a/Tools/LogAnalyzer/DataflashLog.py +++ b/Tools/LogAnalyzer/DataflashLog.py @@ -756,7 +756,7 @@ class DataflashLog(object): else: raise Exception("") else: - if not tokens[0] in self.formats: + if tokens[0] not in self.formats: raise ValueError("Unknown Format {}".format(tokens[0])) e = self.formats[tokens[0]](*tokens[1:]) self.process(lineNumber, e) diff --git a/Tools/Replay/check_replay.py b/Tools/Replay/check_replay.py index 32a49ea555..dbb0a0bf02 100755 --- a/Tools/Replay/check_replay.py +++ b/Tools/Replay/check_replay.py @@ -40,7 +40,7 @@ def check_log(logfile, progress=print, ekf2_only=False, ekf3_only=False, verbose if not hasattr(m,'C'): continue mtype = m.get_type() - if not mtype in counts: + if mtype not in counts: counts[mtype] = 0 base_counts[mtype] = 0 core = m.C diff --git a/Tools/ardupilotwaf/boards.py b/Tools/ardupilotwaf/boards.py index 9a6b7c0a11..f1a51e5fd6 100644 --- a/Tools/ardupilotwaf/boards.py +++ b/Tools/ardupilotwaf/boards.py @@ -614,7 +614,7 @@ Please use a replacement build as follows: ''' % ctx.env.BOARD) boards = _board_classes.keys() - if not ctx.env.BOARD in boards: + if ctx.env.BOARD not in boards: ctx.fatal("Invalid board '%s': choices are %s" % (ctx.env.BOARD, ', '.join(sorted(boards, key=str.lower)))) _board = _board_classes[ctx.env.BOARD]() return _board diff --git a/Tools/ardupilotwaf/chibios.py b/Tools/ardupilotwaf/chibios.py index 83c41cb81d..faf094c4fd 100644 --- a/Tools/ardupilotwaf/chibios.py +++ b/Tools/ardupilotwaf/chibios.py @@ -31,7 +31,7 @@ def _load_dynamic_env_data(bld): # relative paths from the make build are relative to BUILDROOT d = os.path.join(bld.env.BUILDROOT, d) d = os.path.normpath(d) - if not d in idirs2: + if d not in idirs2: idirs2.append(d) _dynamic_env_data['include_dirs'] = idirs2 @@ -98,7 +98,7 @@ class upload_fw(Task.Task): except subprocess.CalledProcessError: #if where.exe can't find the file it returns a non-zero result which throws this exception where_python = "" - if not where_python or not "\Python\Python" in where_python or "python.exe" not in where_python: + if not where_python or "\Python\Python" not in where_python or "python.exe" not in where_python: print(self.get_full_wsl2_error_msg("Windows python.exe not found")) return False return True diff --git a/Tools/ardupilotwaf/mavgen.py b/Tools/ardupilotwaf/mavgen.py index 5af076ac3f..f246d768d5 100644 --- a/Tools/ardupilotwaf/mavgen.py +++ b/Tools/ardupilotwaf/mavgen.py @@ -44,7 +44,7 @@ class mavgen(Task.Task): node.parent.path_from(entry_point.parent), path ) - if not path in names: + if path not in names: names.append(path) return nodes, names diff --git a/Tools/ardupilotwaf/toolchain.py b/Tools/ardupilotwaf/toolchain.py index 5d242a4fc6..eb86084307 100644 --- a/Tools/ardupilotwaf/toolchain.py +++ b/Tools/ardupilotwaf/toolchain.py @@ -119,7 +119,7 @@ def _set_pkgconfig_crosscompilation_wrapper(cfg): @conf def new_validate_cfg(kw): - if not 'path' in kw: + if 'path' not in kw: if not cfg.env.PKGCONFIG: cfg.find_program('%s-pkg-config' % cfg.env.TOOLCHAIN, var='PKGCONFIG') kw['path'] = cfg.env.PKGCONFIG diff --git a/Tools/autotest/arduplane.py b/Tools/autotest/arduplane.py index 5c2eb660e6..65fbb0fa77 100644 --- a/Tools/autotest/arduplane.py +++ b/Tools/autotest/arduplane.py @@ -1130,7 +1130,7 @@ class AutoTestPlane(AutoTest): self.context_collect("HEARTBEAT") self.set_parameter("SIM_RC_FAIL", 2) # throttle-to-950 self.wait_mode('RTL') # long failsafe - if (not self.get_mode_from_mode_mapping("CIRCLE") in + if (self.get_mode_from_mode_mapping("CIRCLE") not in [x.custom_mode for x in self.context_stop_collecting("HEARTBEAT")]): raise NotAchievedException("Did not go via circle mode") self.progress("Ensure we've had our throttle squashed to 950") @@ -1168,7 +1168,7 @@ class AutoTestPlane(AutoTest): self.context_collect("HEARTBEAT") self.set_parameter("SIM_RC_FAIL", 1) # no-pulses self.wait_mode('RTL') # long failsafe - if (not self.get_mode_from_mode_mapping("CIRCLE") in + if (self.get_mode_from_mode_mapping("CIRCLE") not in [x.custom_mode for x in self.context_stop_collecting("HEARTBEAT")]): raise NotAchievedException("Did not go via circle mode") self.do_timesync_roundtrip() diff --git a/Tools/scripts/CAN/fix2_gap.py b/Tools/scripts/CAN/fix2_gap.py index e72d6cceca..1d2f2dd484 100755 --- a/Tools/scripts/CAN/fix2_gap.py +++ b/Tools/scripts/CAN/fix2_gap.py @@ -26,7 +26,7 @@ last_fix2 = {} def handle_fix2(msg): nodeid = msg.transfer.source_node_id tstamp = msg.transfer.ts_real - if not nodeid in last_fix2: + if nodeid not in last_fix2: last_fix2[nodeid] = tstamp return dt = tstamp - last_fix2[nodeid] diff --git a/Tools/scripts/configure_all.py b/Tools/scripts/configure_all.py index 6a799fbe98..442f9bd302 100755 --- a/Tools/scripts/configure_all.py +++ b/Tools/scripts/configure_all.py @@ -43,7 +43,7 @@ def get_board_list(): dirname, dirlist, filenames = next(os.walk('libraries/AP_HAL_ChibiOS/hwdef')) for d in dirlist: hwdef = os.path.join(dirname, d, 'hwdef.dat') - if os.path.exists(hwdef) and not d in omit: + if os.path.exists(hwdef) and d not in omit: board_list.append(d) return board_list diff --git a/Tools/scripts/param_unpack.py b/Tools/scripts/param_unpack.py index 5d4c1c5e59..a439d1ce39 100755 --- a/Tools/scripts/param_unpack.py +++ b/Tools/scripts/param_unpack.py @@ -54,7 +54,7 @@ while True: flags = (ptype>>4) & 0x0F ptype &= 0x0F - if not ptype in data_types: + if ptype not in data_types: raise Exception("bad type 0x%x" % ptype) (type_len, type_format) = data_types[ptype] diff --git a/Tools/scripts/tempcal_IMU.py b/Tools/scripts/tempcal_IMU.py index dcee07b36d..b75dda5607 100755 --- a/Tools/scripts/tempcal_IMU.py +++ b/Tools/scripts/tempcal_IMU.py @@ -65,14 +65,14 @@ class Coefficients: def set_acoeff(self, imu, axis, order, value): if imu not in self.acoef: self.acoef[imu] = {} - if not axis in self.acoef[imu]: + if axis not in self.acoef[imu]: self.acoef[imu][axis] = [0]*4 self.acoef[imu][axis][POLY_ORDER-order] = value def set_gcoeff(self, imu, axis, order, value): if imu not in self.gcoef: self.gcoef[imu] = {} - if not axis in self.gcoef[imu]: + if axis not in self.gcoef[imu]: self.gcoef[imu][axis] = [0]*4 self.gcoef[imu][axis][POLY_ORDER-order] = value @@ -107,7 +107,7 @@ class Coefficients: return 0.0 if cal_temp < -80: return 0.0 - if not axis in coeff: + if axis not in coeff: return 0.0 temperature = constrain(temperature, self.tmin[imu], self.tmax[imu]) cal_temp = constrain(cal_temp, self.tmin[imu], self.tmax[imu])