[Mbed] Add to flake8 in workflow and fix python files (part #25193) (#25249)

* [Mbed] Add to flake8 in workflow and fix python files

* Fix after review
diff --git a/.flake8 b/.flake8
index 1c16dcf..599ac08 100644
--- a/.flake8
+++ b/.flake8
@@ -8,7 +8,6 @@
           # temporarily scan only directories with fixed files
           # TODO: Remove the paths below when all bugs are fixed
           src/tools/chip-cert/*
-          src/test_driver/mbed/*
           build/chip/java/tests/*
           build/chip/linux/*
           build/config/linux/*
@@ -16,7 +15,6 @@
           docs/_extensions/external_content.py
           examples/common/pigweed/rpc_console/py/chip_rpc/console.py
           examples/lighting-app/python/lighting.py
-          examples/platform/mbed/ota/generate_ota_list_image.py
           scripts/build/build/target.py
           scripts/build/build/targets.py
           scripts/build/builders/android.py
diff --git a/examples/platform/mbed/ota/generate_ota_list_image.py b/examples/platform/mbed/ota/generate_ota_list_image.py
index 72c6dd7..989affd 100644
--- a/examples/platform/mbed/ota/generate_ota_list_image.py
+++ b/examples/platform/mbed/ota/generate_ota_list_image.py
@@ -25,7 +25,6 @@
 
 import json
 import os
-import string
 import sys
 
 FILE_NAME = "ota-image-list.json"
diff --git a/src/test_driver/mbed/integration_tests/common/device.py b/src/test_driver/mbed/integration_tests/common/device.py
index 61879f2..9c693a9 100644
--- a/src/test_driver/mbed/integration_tests/common/device.py
+++ b/src/test_driver/mbed/integration_tests/common/device.py
@@ -94,7 +94,6 @@
                 if line:
                     lines.append(line)
                     if search in line:
-                        end = time()
                         return lines
 
             except queue.Empty:
diff --git a/src/test_driver/mbed/integration_tests/common/fixtures.py b/src/test_driver/mbed/integration_tests/common/fixtures.py
index 78b05ca..575c15c 100644
--- a/src/test_driver/mbed/integration_tests/common/fixtures.py
+++ b/src/test_driver/mbed/integration_tests/common/fixtures.py
@@ -15,7 +15,7 @@
 
 import logging
 from time import sleep
-from typing import Any, List, Mapping, Optional
+from typing import Any, List, Mapping
 
 import mbed_lstools
 import pytest
diff --git a/src/test_driver/mbed/integration_tests/common/pigweed_client.py b/src/test_driver/mbed/integration_tests/common/pigweed_client.py
index 6a770d3..9d7d6a3 100644
--- a/src/test_driver/mbed/integration_tests/common/pigweed_client.py
+++ b/src/test_driver/mbed/integration_tests/common/pigweed_client.py
@@ -13,10 +13,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import importlib
-import os
-from pathlib import Path
-
 from pw_hdlc.rpc import HdlcRpcClient, default_channels
 
 
diff --git a/src/test_driver/mbed/integration_tests/common/utils.py b/src/test_driver/mbed/integration_tests/common/utils.py
index 02529d4..036b612 100644
--- a/src/test_driver/mbed/integration_tests/common/utils.py
+++ b/src/test_driver/mbed/integration_tests/common/utils.py
@@ -15,7 +15,6 @@
 
 
 import logging
-import os
 import platform
 import random
 import re
@@ -48,7 +47,7 @@
     :return: device details dictionary or None
     """
     ret = device.wait_for_output("SetupQRCode")
-    if ret == None or len(ret) < 2:
+    if ret is None or len(ret) < 2:
         return None
 
     qr_code = re.sub(
@@ -119,13 +118,13 @@
             raise exceptions.UnknownCluster(args[0])
         command = all_commands.get(args[0]).get(args[1], None)
         # When command takes no arguments, (not command) is True
-        if command == None:
+        if command is None:
             raise exceptions.UnknownCommand(args[0], args[1])
         err, res = devCtrl.ZCLSend(args[0], args[1], int(
             args[2]), int(args[3]), int(args[4]), FormatZCLArguments(args[5:], command), blocking=True)
         if err != 0:
             log.error("Failed to send ZCL command [{}] {}.".format(err, res))
-        elif res != None:
+        elif res is not None:
             log.info("Success, received command response:")
             log.info(res)
         else:
@@ -145,7 +144,7 @@
 def scan_chip_ble_devices(devCtrl):
     """
     BLE scan CHIP device
-    BLE scanning for 10 seconds and collect the results 
+    BLE scanning for 10 seconds and collect the results
     :param devCtrl: device controller instance
     :return: List of visible BLE devices
     """
@@ -173,14 +172,14 @@
     :return: True if device advertise else False
     """
     ble_chip_device = scan_chip_ble_devices(devCtrl)
-    if ble_chip_device == None or len(ble_chip_device) == 0:
+    if ble_chip_device is None or len(ble_chip_device) == 0:
         log.info("No BLE CHIP device found")
         return False
 
     chip_device_found = False
 
     for ble_device in ble_chip_device:
-        if deviceDetails != None:
+        if deviceDetails is not None:
             if (ble_device["name"] == name and
                 int(ble_device["discriminator"]) == int(deviceDetails["Discriminator"]) and
                 int(ble_device["vendorId"]) == int(deviceDetails["VendorID"]) and
@@ -197,14 +196,14 @@
 
 def connect_device_over_ble(devCtrl, discriminator, pinCode, nodeId=None):
     """
-    Connect to Matter accessory device over BLE 
+    Connect to Matter accessory device over BLE
     :param devCtrl: device controller instance
     :param discriminator: CHIP device discriminator
     :param pinCode: CHIP device pin code
     :param nodeId: default value of node ID
     :return: node ID is provisioning successful, otherwise None
     """
-    if nodeId == None:
+    if nodeId is None:
         nodeId = random.randint(1, 1000000)
 
     try:
@@ -248,7 +247,7 @@
 
 def commissioning_wifi(devCtrl, ssid, password, nodeId):
     """
-    Commissioning a Wi-Fi device 
+    Commissioning a Wi-Fi device
     :param devCtrl: device controller instance
     :param ssid: network ssid
     :param password: network password
@@ -257,8 +256,14 @@
     """
 
     # Inject the credentials to the device
-    err, res = send_zcl_command(
-        devCtrl, "NetworkCommissioning AddOrUpdateWiFiNetwork {} 0 0 ssid=str:{} credentials=str:{} breadcrumb=0 timeoutMs=1000".format(nodeId, ssid, password))
+    err, res = send_zcl_command(devCtrl,
+                                "NetworkCommissioning "
+                                "AddOrUpdateWiFiNetwork {} 0 0 "
+                                "ssid=str:{} credentials=str:{} breadcrumb=0 timeoutMs=1000".format(
+                                    nodeId,
+                                    ssid,
+                                    password
+                                ))
     if err != 0 and res["Status"] != 0:
         log.error("Set Wi-Fi credentials failed [{}]".format(err))
         return err
@@ -284,7 +289,7 @@
     try:
         devCtrl.ResolveNode(int(nodeId))
         ret = devCtrl.GetAddressAndPort(int(nodeId))
-        if ret == None:
+        if ret is None:
             log.error("Get address and port failed")
     except exceptions.ChipStackException as ex:
         log.error("Resolve node failed {}".format(str(ex)))
diff --git a/src/test_driver/mbed/integration_tests/conftest.py b/src/test_driver/mbed/integration_tests/conftest.py
index 56f549b..1d64d8d 100644
--- a/src/test_driver/mbed/integration_tests/conftest.py
+++ b/src/test_driver/mbed/integration_tests/conftest.py
@@ -13,8 +13,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import pytest
-
 pytest_plugins = ['common.fixtures']
 
 
diff --git a/src/test_driver/mbed/integration_tests/lighting-app/test_app.py b/src/test_driver/mbed/integration_tests/lighting-app/test_app.py
index 6e4608e..67041a6 100644
--- a/src/test_driver/mbed/integration_tests/lighting-app/test_app.py
+++ b/src/test_driver/mbed/integration_tests/lighting-app/test_app.py
@@ -20,7 +20,8 @@
 from button_service import button_service_pb2
 from chip import ChipDeviceCtrl
 from common.pigweed_client import PigweedClient
-from common.utils import *
+from common.utils import (check_chip_ble_devices_advertising, close_ble, close_connection, commissioning_wifi,
+                          connect_device_over_ble, get_device_details, resolve_device, send_zcl_command)
 from device_service import device_service_pb2
 from lighting_service import lighting_service_pb2
 from pw_status import Status
@@ -37,9 +38,9 @@
 def test_smoke_test(device):
     device.reset(duration=1)
     ret = device.wait_for_output("Mbed lighting-app example application start")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
     ret = device.wait_for_output("Mbed lighting-app example application run")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
 
 def test_wifi_provisioning(device, network):
@@ -49,35 +50,34 @@
     devCtrl = ChipDeviceCtrl.ChipDeviceController()
 
     device_details = get_device_details(device)
-    assert device_details != None and len(device_details) != 0
+    assert device_details is not None and len(device_details) != 0
 
     assert check_chip_ble_devices_advertising(
         devCtrl, BLE_DEVICE_NAME, device_details)
 
     ret = connect_device_over_ble(devCtrl, int(device_details["Discriminator"]), int(
         device_details["SetUpPINCode"]), DEVICE_NODE_ID)
-    assert ret != None and ret == DEVICE_NODE_ID
+    assert ret is not None and ret == DEVICE_NODE_ID
 
     ret = device.wait_for_output("Device completed Rendezvous process")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
     ret = commissioning_wifi(devCtrl, network_ssid,
                              network_pass, DEVICE_NODE_ID)
     assert ret == 0
 
     ret = device.wait_for_output("StationConnected")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
     ret = device.wait_for_output("address set")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
     device_ip_address = ret[-1].partition("address set:")[2].strip()
 
     ret = resolve_device(devCtrl, DEVICE_NODE_ID)
-    assert ret != None and len(ret) == 2
+    assert ret is not None and len(ret) == 2
 
     ip_address = ret[0]
-    port = ret[1]
 
     assert device_ip_address == ip_address
 
@@ -92,53 +92,54 @@
     devCtrl = ChipDeviceCtrl.ChipDeviceController()
 
     device_details = get_device_details(device)
-    assert device_details != None and len(device_details) != 0
+    assert device_details is not None and len(device_details) != 0
 
     assert check_chip_ble_devices_advertising(
         devCtrl, BLE_DEVICE_NAME, device_details)
 
     ret = connect_device_over_ble(devCtrl, int(device_details["Discriminator"]), int(
         device_details["SetUpPINCode"]), DEVICE_NODE_ID)
-    assert ret != None and ret == DEVICE_NODE_ID
+    assert ret is not None and ret == DEVICE_NODE_ID
 
     ret = device.wait_for_output("Device completed Rendezvous process")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
     ret = commissioning_wifi(devCtrl, network_ssid,
                              network_pass, DEVICE_NODE_ID)
     assert ret == 0
 
     ret = resolve_device(devCtrl, DEVICE_NODE_ID)
-    assert ret != None and len(ret) == 2
+    assert ret is not None and len(ret) == 2
 
     err, res = send_zcl_command(
         devCtrl, "OnOff On {} 1 0".format(DEVICE_NODE_ID))
     assert err == 0
 
     ret = device.wait_for_output("Turn On Action has been completed", 20)
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
     err, res = send_zcl_command(
         devCtrl, "OnOff Off {} 1 0".format(DEVICE_NODE_ID))
     assert err == 0
 
     ret = device.wait_for_output("Turn Off Action has been completed", 20)
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
     err, res = send_zcl_command(
         devCtrl, "OnOff Toggle {} 1 0".format(DEVICE_NODE_ID))
     assert err == 0
 
     ret = device.wait_for_output("Turn On Action has been completed", 20)
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
-    err, res = send_zcl_command(devCtrl, "LevelControl MoveToLevel {} 1 0 level={} transitionTime=1 optionMask=0 optionOverride=0".format(
-        DEVICE_NODE_ID, TEST_BRIGHTNESS_LEVEL))
+    err, res = send_zcl_command(devCtrl,
+                                "LevelControl MoveToLevel {} 1 0 level={} transitionTime=1 optionMask=0 optionOverride=0".format(
+                                    DEVICE_NODE_ID, TEST_BRIGHTNESS_LEVEL))
     assert err == 0
 
     ret = device.wait_for_output(
         "Setting brightness level to {}".format(TEST_BRIGHTNESS_LEVEL), 20)
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
     assert close_connection(devCtrl, DEVICE_NODE_ID)
     assert close_ble(devCtrl)
@@ -147,11 +148,11 @@
 def test_device_info_rpc(device):
     pw_client = PigweedClient(device, RPC_PROTOS)
     status, payload = pw_client.rpcs.chip.rpc.Device.GetDeviceInfo()
-    assert status.ok() == True
-    assert payload.vendor_id != None and payload.product_id != None and payload.serial_number != None
+    assert status.ok() is True
+    assert payload.vendor_id is not None and payload.product_id is not None and payload.serial_number is not None
 
     device_details = get_device_details(device)
-    assert device_details != None and len(device_details) != 0
+    assert device_details is not None and len(device_details) != 0
 
     assert int(device_details["VendorID"]) == payload.vendor_id
     assert int(device_details["ProductID"]) == payload.product_id
@@ -163,7 +164,7 @@
 def test_device_factory_reset_rpc(device):
     pw_client = PigweedClient(device, RPC_PROTOS)
     status, payload = pw_client.rpcs.chip.rpc.Device.FactoryReset()
-    assert status.ok() == True
+    assert status.ok() is True
 
 
 def test_device_reboot_rpc(device):
@@ -183,17 +184,17 @@
 
     # Check light on
     status, payload = pw_client.rpcs.chip.rpc.Lighting.Set(on=True)
-    assert status.ok() == True
+    assert status.ok() is True
     status, payload = pw_client.rpcs.chip.rpc.Lighting.Get()
-    assert status.ok() == True
-    assert payload.on == True
+    assert status.ok() is True
+    assert payload.on is True
 
     # Check light off
     status, payload = pw_client.rpcs.chip.rpc.Lighting.Set(on=False)
-    assert status.ok() == True
+    assert status.ok() is True
     status, payload = pw_client.rpcs.chip.rpc.Lighting.Get()
-    assert status.ok() == True
-    assert payload.on == False
+    assert status.ok() is True
+    assert payload.on is False
 
 
 def test_button_ctrl_rpc(device):
@@ -201,21 +202,21 @@
 
     # Check button 0 (lighting)
     status, payload = pw_client.rpcs.chip.rpc.Lighting.Get()
-    assert status.ok() == True
+    assert status.ok() is True
     initial_state = bool(payload.on)
 
     compare_state = not initial_state
     status, payload = pw_client.rpcs.chip.rpc.Button.Event(idx=0, pushed=True)
-    assert status.ok() == True
+    assert status.ok() is True
     sleep(2)
     status, payload = pw_client.rpcs.chip.rpc.Lighting.Get()
-    assert status.ok() == True
+    assert status.ok() is True
     assert payload.on == compare_state
 
     compare_state = initial_state
     status, payload = pw_client.rpcs.chip.rpc.Button.Event(idx=0, pushed=True)
-    assert status.ok() == True
+    assert status.ok() is True
     sleep(2)
     status, payload = pw_client.rpcs.chip.rpc.Lighting.Get()
-    assert status.ok() == True
+    assert status.ok() is True
     assert payload.on == compare_state
diff --git a/src/test_driver/mbed/integration_tests/lock-app/test_app.py b/src/test_driver/mbed/integration_tests/lock-app/test_app.py
index e22d92c..0592846 100644
--- a/src/test_driver/mbed/integration_tests/lock-app/test_app.py
+++ b/src/test_driver/mbed/integration_tests/lock-app/test_app.py
@@ -20,7 +20,8 @@
 from button_service import button_service_pb2
 from chip import ChipDeviceCtrl
 from common.pigweed_client import PigweedClient
-from common.utils import *
+from common.utils import (check_chip_ble_devices_advertising, close_ble, close_connection, commissioning_wifi,
+                          connect_device_over_ble, get_device_details, resolve_device, send_zcl_command)
 from device_service import device_service_pb2
 from locking_service import locking_service_pb2
 from pw_status import Status
@@ -36,9 +37,9 @@
 def test_smoke_test(device):
     device.reset(duration=1)
     ret = device.wait_for_output("Mbed lock-app example application start")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
     ret = device.wait_for_output("Mbed lock-app example application run")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
 
 def test_wifi_provisioning(device, network):
@@ -48,35 +49,34 @@
     devCtrl = ChipDeviceCtrl.ChipDeviceController()
 
     device_details = get_device_details(device)
-    assert device_details != None and len(device_details) != 0
+    assert device_details is not None and len(device_details) != 0
 
     assert check_chip_ble_devices_advertising(
         devCtrl, BLE_DEVICE_NAME, device_details)
 
     ret = connect_device_over_ble(devCtrl, int(device_details["Discriminator"]), int(
         device_details["SetUpPINCode"]), DEVICE_NODE_ID)
-    assert ret != None and ret == DEVICE_NODE_ID
+    assert ret is not None and ret == DEVICE_NODE_ID
 
     ret = device.wait_for_output("Device completed Rendezvous process")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
     ret = commissioning_wifi(devCtrl, network_ssid,
                              network_pass, DEVICE_NODE_ID)
     assert ret == 0
 
     ret = device.wait_for_output("StationConnected")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
     ret = device.wait_for_output("address set")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
     device_ip_address = ret[-1].partition("address set:")[2].strip()
 
     ret = resolve_device(devCtrl, DEVICE_NODE_ID)
-    assert ret != None and len(ret) == 2
+    assert ret is not None and len(ret) == 2
 
     ip_address = ret[0]
-    port = ret[1]
 
     assert device_ip_address == ip_address
 
@@ -91,45 +91,45 @@
     devCtrl = ChipDeviceCtrl.ChipDeviceController()
 
     device_details = get_device_details(device)
-    assert device_details != None and len(device_details) != 0
+    assert device_details is not None and len(device_details) != 0
 
     assert check_chip_ble_devices_advertising(
         devCtrl, BLE_DEVICE_NAME, device_details)
 
     ret = connect_device_over_ble(devCtrl, int(device_details["Discriminator"]), int(
         device_details["SetUpPINCode"]), DEVICE_NODE_ID)
-    assert ret != None and ret == DEVICE_NODE_ID
+    assert ret is not None and ret == DEVICE_NODE_ID
 
     ret = device.wait_for_output("Device completed Rendezvous process")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
     ret = commissioning_wifi(devCtrl, network_ssid,
                              network_pass, DEVICE_NODE_ID)
     assert ret == 0
 
     ret = resolve_device(devCtrl, DEVICE_NODE_ID)
-    assert ret != None and len(ret) == 2
+    assert ret is not None and len(ret) == 2
 
     err, res = send_zcl_command(
         devCtrl, "OnOff Off {} 1 0".format(DEVICE_NODE_ID))
     assert err == 0
 
     ret = device.wait_for_output("Unlock Action has been completed", 20)
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
     err, res = send_zcl_command(
         devCtrl, "OnOff On {} 1 0".format(DEVICE_NODE_ID))
     assert err == 0
 
     ret = device.wait_for_output("Lock Action has been completed", 20)
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
     err, res = send_zcl_command(
         devCtrl, "OnOff Toggle {} 1 0".format(DEVICE_NODE_ID))
     assert err == 0
 
     ret = device.wait_for_output("Unlock Action has been completed", 20)
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
     assert close_connection(devCtrl, DEVICE_NODE_ID)
     assert close_ble(devCtrl)
@@ -138,11 +138,11 @@
 def test_device_info_rpc(device):
     pw_client = PigweedClient(device, RPC_PROTOS)
     status, payload = pw_client.rpcs.chip.rpc.Device.GetDeviceInfo()
-    assert status.ok() == True
-    assert payload.vendor_id != None and payload.product_id != None and payload.serial_number != None
+    assert status.ok() is True
+    assert payload.vendor_id is not None and payload.product_id is not None and payload.serial_number is not None
 
     device_details = get_device_details(device)
-    assert device_details != None and len(device_details) != 0
+    assert device_details is not None and len(device_details) != 0
 
     assert int(device_details["VendorID"]) == payload.vendor_id
     assert int(device_details["ProductID"]) == payload.product_id
@@ -154,7 +154,7 @@
 def test_device_factory_reset_rpc(device):
     pw_client = PigweedClient(device, RPC_PROTOS)
     status, payload = pw_client.rpcs.chip.rpc.Device.FactoryReset()
-    assert status.ok() == True
+    assert status.ok() is True
 
 
 def test_device_reboot_rpc(device):
@@ -174,17 +174,17 @@
 
     # Check locked
     status, payload = pw_client.rpcs.chip.rpc.Locking.Set(locked=True)
-    assert status.ok() == True
+    assert status.ok() is True
     status, payload = pw_client.rpcs.chip.rpc.Locking.Get()
-    assert status.ok() == True
-    assert payload.locked == True
+    assert status.ok() is True
+    assert payload.locked is True
 
     # Check unlocked
     status, payload = pw_client.rpcs.chip.rpc.Locking.Set(locked=False)
-    assert status.ok() == True
+    assert status.ok() is True
     status, payload = pw_client.rpcs.chip.rpc.Locking.Get()
-    assert status.ok() == True
-    assert payload.locked == False
+    assert status.ok() is True
+    assert payload.locked is False
 
 
 def test_button_ctrl_rpc(device):
@@ -192,21 +192,21 @@
 
     # Check button 0 (locking)
     status, payload = pw_client.rpcs.chip.rpc.Locking.Get()
-    assert status.ok() == True
+    assert status.ok() is True
     initial_state = bool(payload.locked)
 
     compare_state = not initial_state
     status, payload = pw_client.rpcs.chip.rpc.Button.Event(idx=0, pushed=True)
-    assert status.ok() == True
+    assert status.ok() is True
     sleep(2)
     status, payload = pw_client.rpcs.chip.rpc.Locking.Get()
-    assert status.ok() == True
-    assert payload.locked == compare_state
+    assert status.ok() is True
+    assert payload.locked is compare_state
 
     compare_state = initial_state
     status, payload = pw_client.rpcs.chip.rpc.Button.Event(idx=0, pushed=True)
-    assert status.ok() == True
+    assert status.ok() is True
     sleep(2)
     status, payload = pw_client.rpcs.chip.rpc.Locking.Get()
-    assert status.ok() == True
+    assert status.ok() is True
     assert payload.locked == compare_state
diff --git a/src/test_driver/mbed/integration_tests/pigweed-app/test_app.py b/src/test_driver/mbed/integration_tests/pigweed-app/test_app.py
index 04f5aa9..4d14d47 100644
--- a/src/test_driver/mbed/integration_tests/pigweed-app/test_app.py
+++ b/src/test_driver/mbed/integration_tests/pigweed-app/test_app.py
@@ -25,14 +25,14 @@
 def test_smoke_test(device):
     device.reset(duration=1)
     ret = device.wait_for_output("Mbed pigweed-app example application start")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
     ret = device.wait_for_output("Mbed pigweed-app example application run")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
 
 def test_echo(device):
     pw_client = PigweedClient(device, RPC_PROTOS)
     status, payload = pw_client.rpcs.pw.rpc.EchoService.Echo(
         msg=PW_ECHO_TEST_MESSAGE)
-    assert status.ok() == True
+    assert status.ok() is True
     assert payload.msg == PW_ECHO_TEST_MESSAGE
diff --git a/src/test_driver/mbed/integration_tests/shell/test_app.py b/src/test_driver/mbed/integration_tests/shell/test_app.py
index 1a6b9b1..7cc994a 100644
--- a/src/test_driver/mbed/integration_tests/shell/test_app.py
+++ b/src/test_driver/mbed/integration_tests/shell/test_app.py
@@ -14,13 +14,12 @@
 # limitations under the License.
 
 import logging
-import re
 from time import sleep
 
 import pytest
 from chip import ChipDeviceCtrl, exceptions
 from chip.setup_payload import SetupPayload
-from common.utils import *
+from common.utils import check_chip_ble_devices_advertising
 from packaging import version
 
 log = logging.getLogger(__name__)
@@ -65,33 +64,33 @@
 def test_smoke_test(device):
     device.reset(duration=1)
     ret = device.wait_for_output("Mbed shell example application start")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
     ret = device.wait_for_output("Mbed shell example application run")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
 
 def test_help_check(device):
     ret = device.send(command="help", expected_output="Done")
-    assert ret != None and len(ret) > 1
+    assert ret is not None and len(ret) > 1
     shell_commands = get_shell_command(ret[1:-1])
     assert set(SHELL_COMMAND_NAME) == set(shell_commands)
 
 
 def test_echo_check(device):
     ret = device.send(command="echo Hello", expected_output="Done")
-    assert ret != None and len(ret) > 1
+    assert ret is not None and len(ret) > 1
     assert "Hello" in ret[-2]
 
 
 def test_log_check(device):
     ret = device.send(command="log Hello", expected_output="Done")
-    assert ret != None and len(ret) > 1
+    assert ret is not None and len(ret) > 1
     assert "[INFO][CHIP]: [TOO]Hello" in ret[-2]
 
 
 def test_rand_check(device):
     ret = device.send(command="rand", expected_output="Done")
-    assert ret != None and len(ret) > 1
+    assert ret is not None and len(ret) > 1
     assert ret[-2].rstrip().isdigit()
 
 
@@ -99,17 +98,17 @@
     hex_string = "1234"
     ret = device.send(command="base64 encode {}".format(
         hex_string), expected_output="Done")
-    assert ret != None and len(ret) > 1
+    assert ret is not None and len(ret) > 1
     base64code = ret[-2]
     ret = device.send(command="base64 decode {}".format(
         base64code), expected_output="Done")
-    assert ret != None and len(ret) > 1
+    assert ret is not None and len(ret) > 1
     assert ret[-2].rstrip() == hex_string
 
 
 def test_version_check(device):
     ret = device.send(command="version", expected_output="Done")
-    assert ret != None and len(ret) > 1
+    assert ret is not None and len(ret) > 1
     assert "CHIP" in ret[-2].split()[0]
     app_version = ret[-2].split()[1]
     assert isinstance(version.parse(app_version), version.Version)
@@ -119,9 +118,9 @@
     devCtrl = ChipDeviceCtrl.ChipDeviceController()
 
     ret = device.send(command="ble adv start", expected_output="Done")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
     ret = device.send(command="ble adv state", expected_output="Done")
-    assert ret != None and len(ret) > 1
+    assert ret is not None and len(ret) > 1
     assert "enabled" in ret[-2].split()[-1]
 
     sleep(1)
@@ -129,9 +128,9 @@
     assert check_chip_ble_devices_advertising(devCtrl, BLE_DEVICE_NAME)
 
     ret = device.send(command="ble adv stop", expected_output="Done")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
     ret = device.send(command="ble adv state", expected_output="Done")
-    assert ret != None and len(ret) > 1
+    assert ret is not None and len(ret) > 1
     assert "disabled" in ret[-2].split()[-1]
 
     sleep(1)
@@ -141,14 +140,14 @@
 
 def test_device_config_check(device):
     ret = device.send(command="config", expected_output="Done")
-    assert ret != None and len(ret) > 2
+    assert ret is not None and len(ret) > 2
 
     config = parse_config_response(ret[1:-1])
 
     for param_name, value in config.items():
         ret = device.send(command="config {}".format(
             param_name), expected_output="Done")
-        assert ret != None and len(ret) > 1
+        assert ret is not None and len(ret) > 1
         if "discriminator" in param_name:
             assert int(ret[-2].split()[0], 16) == value
         else:
@@ -157,24 +156,24 @@
     new_value = int(config['discriminator']) + 1
     ret = device.send(command="config discriminator {}".format(
         new_value), expected_output="Done")
-    assert ret != None and len(ret) > 1
+    assert ret is not None and len(ret) > 1
     assert "Setup discriminator set to: {}".format(new_value) in ret[-2]
 
     ret = device.send(command="config discriminator", expected_output="Done")
-    assert ret != None and len(ret) > 1
+    assert ret is not None and len(ret) > 1
     assert int(ret[-2].split()[0], 16) == new_value
 
 
 def test_on_boarding_codes(device):
     ret = device.send(command="onboardingcodes", expected_output="Done")
-    assert ret != None and len(ret) > 2
+    assert ret is not None and len(ret) > 2
 
     boarding_codes = parse_boarding_codes_response(ret[1:-1])
 
     for param, value in boarding_codes.items():
         ret = device.send(command="onboardingcodes {}".format(
             param), expected_output="Done")
-        assert ret != None and len(ret) > 1
+        assert ret is not None and len(ret) > 1
         assert value == ret[-2].strip()
 
     try:
@@ -183,7 +182,7 @@
     except exceptions.ChipStackError as ex:
         log.error(ex.msg)
         assert False
-    assert device_details != None and len(device_details) != 0
+    assert device_details is not None and len(device_details) != 0
 
     try:
         device_details = dict(SetupPayload().ParseManualPairingCode(
@@ -191,23 +190,23 @@
     except exceptions.ChipStackError as ex:
         log.error(ex.msg)
         assert False
-    assert device_details != None and len(device_details) != 0
+    assert device_details is not None and len(device_details) != 0
 
 
 def test_wifi_mode(device):
     ret = device.send(command="wifi mode", expected_output="Done")
-    assert ret != None and len(ret) > 1
+    assert ret is not None and len(ret) > 1
     current_mode = ret[-2].strip()
     assert current_mode in WIFI_MODE_NAME
 
-    for mode in [n for n in WIFI_MODE_NAME if n != current_mode]:
+    for mode in [n for n in WIFI_MODE_NAME if n == current_mode]:
         print(mode)
         ret = device.send(command="wifi mode {}".format(
             mode), expected_output="Done")
-        assert ret != None and len(ret) > 0
+        assert ret is not None and len(ret) > 0
 
         ret = device.send(command="wifi mode", expected_output="Done")
-        assert ret != None and len(ret) > 1
+        assert ret is not None and len(ret) > 1
         assert ret[-2].strip() == mode
 
 
@@ -217,10 +216,10 @@
 
     ret = device.send(command="wifi connect {} {}".format(
         network_ssid, network_pass), expected_output="Done")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
     ret = device.wait_for_output("StationConnected", 30)
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
 
 def test_device_factory_reset(device):
@@ -229,11 +228,11 @@
     sleep(1)
 
     ret = device.wait_for_output("Mbed shell example application start")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
     ret = device.wait_for_output("Mbed shell example application run")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
 
 def test_exit_check(device):
     ret = device.send(command="exit", expected_output="Goodbye")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
diff --git a/src/test_driver/mbed/integration_tests/unit-tests/test_app.py b/src/test_driver/mbed/integration_tests/unit-tests/test_app.py
index 9f92907..d6e5725 100644
--- a/src/test_driver/mbed/integration_tests/unit-tests/test_app.py
+++ b/src/test_driver/mbed/integration_tests/unit-tests/test_app.py
@@ -15,16 +15,14 @@
 
 import re
 
-import pytest
-
 
 def test_unit_tests(device):
     device.reset(duration=1)
     # smoke test
     ret = device.wait_for_output("Mbed unit-tests application start")
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
     ret = device.wait_for_output("Mbed unit-tests application run", 60)
-    assert ret != None and len(ret) > 0
+    assert ret is not None and len(ret) > 0
 
     ret = device.wait_for_output("CHIP test status:", 500)
     # extract number of failures: