diff --git a/scripts/build/builders/infineon.py b/scripts/build/builders/infineon.py index 58b36bc370ef57..1a8afbb20d0523 100644 --- a/scripts/build/builders/infineon.py +++ b/scripts/build/builders/infineon.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging import os from enum import Enum, auto diff --git a/scripts/examples/gn_to_cmakelists.py b/scripts/examples/gn_to_cmakelists.py index 3d23b9c5945ffc..7449cf57fdaf6a 100755 --- a/scripts/examples/gn_to_cmakelists.py +++ b/scripts/examples/gn_to_cmakelists.py @@ -96,9 +96,11 @@ def SetVariable(out, variable_name, value): def SetVariableList(out, variable_name, values): """Sets a CMake variable to a list.""" if not values: - return SetVariable(out, variable_name, "") + SetVariable(out, variable_name, "") + return if len(values) == 1: - return SetVariable(out, variable_name, values[0]) + SetVariable(out, variable_name, values[0]) + return out.write('list(APPEND "') out.write(CMakeStringEscape(variable_name)) out.write('"\n "') diff --git a/scripts/flashing/nrfconnect_firmware_utils.py b/scripts/flashing/nrfconnect_firmware_utils.py index 3f57a9cfb1c8fc..ea7d68faaede25 100755 --- a/scripts/flashing/nrfconnect_firmware_utils.py +++ b/scripts/flashing/nrfconnect_firmware_utils.py @@ -131,7 +131,6 @@ def flash(self, image): def reset(self): """Reset the device.""" return self.run_tool('nrfjprog', ['--pinresetenable'], name='Enable pin reset') - return self.run_tool('nrfjprog', ['--pinreset'], name='Apply pin reset') def actions(self): """Perform actions on the device according to self.option.""" diff --git a/scripts/tools/memory/collect.py b/scripts/tools/memory/collect.py index 5c0a48e39183d2..1eeb66e02e7216 100755 --- a/scripts/tools/memory/collect.py +++ b/scripts/tools/memory/collect.py @@ -42,7 +42,6 @@ def main(argv): memdf.report.write_dfs(config, memdf.collect.collect_files(config)) except Exception as exception: - status = 1 raise exception return status diff --git a/scripts/tools/memory/report_summary.py b/scripts/tools/memory/report_summary.py index 99b055ad81de32..3b21f6a88bb8ea 100755 --- a/scripts/tools/memory/report_summary.py +++ b/scripts/tools/memory/report_summary.py @@ -28,7 +28,7 @@ import sys -import numpy as np # type: ignore +import numpy # type: ignore import memdf.collect import memdf.report diff --git a/src/controller/python/chip-device-ctrl.py b/src/controller/python/chip-device-ctrl.py index 776da14331061e..0ee6c2d359c601 100755 --- a/src/controller/python/chip-device-ctrl.py +++ b/src/controller/python/chip-device-ctrl.py @@ -445,9 +445,7 @@ def do_blescan(self, line): def ConnectFromSetupPayload(self, setupPayload, nodeid): # TODO(cecille): Get this from the C++ code? - softap = 1 << 0 ble = 1 << 1 - onnetwork = 1 << 2 # Devices may be uncommissioned, or may already be on the network. Need to check both ways. # TODO(cecille): implement soft-ap connection. @@ -720,7 +718,7 @@ def do_zcl(self, line): 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 = self.devCtrl.ZCLSend(args[0], args[1], int( args[2]), int(args[3]), int(args[4]), FormatZCLArguments(args[5:], command), blocking=True) @@ -737,7 +735,6 @@ def do_zcl(self, line): print("An exception occurred during process ZCL command:") print(str(ex)) except Exception as ex: - import traceback print("An exception occurred during processing input:") traceback.print_exc() print(str(ex)) diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index f7f2f328b93559..5cce8498f74051 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -371,7 +371,7 @@ def ZCLReadAttribute(self, cluster, attribute, nodeid, endpoint, groupid, blocki device = self.GetConnectedDeviceSync(nodeid) # We are not using IM for Attributes. - res = self._Cluster.ReadAttribute( + self._Cluster.ReadAttribute( device, cluster, attribute, endpoint, groupid, False) if blocking: return im.GetAttributeReadResponse(im.DEFAULT_ATTRIBUTEREAD_APPID) @@ -390,7 +390,7 @@ def ZCLSubscribeAttribute(self, cluster, attribute, nodeid, endpoint, minInterva commandSenderHandle = self._dmLib.pychip_GetCommandSenderHandle(device) im.ClearCommandStatus(commandSenderHandle) - res = self._Cluster.SubscribeAttribute( + self._Cluster.SubscribeAttribute( device, cluster, attribute, endpoint, minInterval, maxInterval, commandSenderHandle != 0) if blocking: # We only send 1 command by this function, so index is always 0 diff --git a/src/controller/python/chip/clusters/Command.py b/src/controller/python/chip/clusters/Command.py index 1936ba3707f074..9348e3bd591432 100644 --- a/src/controller/python/chip/clusters/Command.py +++ b/src/controller/python/chip/clusters/Command.py @@ -68,7 +68,6 @@ def _handleError(self, imError: int, chipError: int, exception: Exception): except: self._future.set_exception(chip.interaction_model.InteractionModelError( chip.interaction_model.Status.Failure)) - pass def handleError(self, imError: int, chipError: int): self._event_loop.call_soon_threadsafe( diff --git a/src/controller/python/chip/clusters/TestObjects.py b/src/controller/python/chip/clusters/TestObjects.py index d980d98975bb7a..0ff413e74569bc 100644 --- a/src/controller/python/chip/clusters/TestObjects.py +++ b/src/controller/python/chip/clusters/TestObjects.py @@ -18,7 +18,7 @@ from dataclasses import dataclass import typing -from .ClusterObjects import ClusterObject, ClusterObjectDescriptor, ClusterObjectFieldDescriptor, ClusterCommand +from .ClusterObjects import ClusterObjectDescriptor, ClusterCommand from chip import ChipUtility from enum import IntEnum diff --git a/src/controller/python/chip/discovery/library_handle.py b/src/controller/python/chip/discovery/library_handle.py index 73b719d0de73f3..edf31631e3ac78 100644 --- a/src/controller/python/chip/discovery/library_handle.py +++ b/src/controller/python/chip/discovery/library_handle.py @@ -16,7 +16,6 @@ import chip.native import ctypes -from ctypes import c_uint32, c_uint64 from chip.discovery.types import DiscoverSuccessCallback_t, DiscoverFailureCallback_t @@ -34,7 +33,8 @@ def _GetDiscoveryLibraryHandle() -> ctypes.CDLL: if not handle.pychip_discovery_resolve.argtypes: setter = chip.native.NativeLibraryHandleMethodArguments(handle) - setter.Set('pychip_discovery_resolve', c_uint32, [c_uint64, c_uint64]) + setter.Set('pychip_discovery_resolve', ctypes.c_uint32, + [ctypes.c_uint64, ctypes.c_uint64]) setter.Set('pychip_discovery_set_callbacks', None, [ DiscoverSuccessCallback_t, DiscoverFailureCallback_t]) diff --git a/src/controller/python/chip/internal/commissioner.py b/src/controller/python/chip/internal/commissioner.py index ce264ab2df2096..7976c93c09c5ca 100644 --- a/src/controller/python/chip/internal/commissioner.py +++ b/src/controller/python/chip/internal/commissioner.py @@ -15,7 +15,6 @@ # from chip.configuration import GetLocalNodeId from chip.native import NativeLibraryHandleMethodArguments, GetLibraryHandle -from ctypes import c_uint64, c_uint32, c_uint16 from enum import Enum from typing import Optional from chip.internal.types import NetworkCredentialsRequested, OperationalCredentialsRequested, PairingComplete @@ -103,11 +102,12 @@ def _SetNativeCallSignatues(handle: ctypes.CDLL): """Sets up the FFI types for the cdll handle.""" setter = NativeLibraryHandleMethodArguments(handle) - setter.Set('pychip_internal_Commissioner_New', Commissioner_p, [c_uint64]) + setter.Set('pychip_internal_Commissioner_New', + Commissioner_p, [ctypes.c_uint64]) setter.Set('pychip_internal_Commissioner_Unpair', - c_uint32, [Commissioner_p, c_uint64]) + ctypes.c_uint32, [Commissioner_p, ctypes.c_uint64]) setter.Set('pychip_internal_Commissioner_BleConnectForPairing', - c_uint32, [Commissioner_p, c_uint64, c_uint32, c_uint16]) + ctypes.c_uint32, [Commissioner_p, ctypes.c_uint64, ctypes.c_uint32, cctypes._uint16]) setter.Set('pychip_internal_PairingDelegate_SetPairingCompleteCallback', None, [ PairingComplete]) diff --git a/src/controller/python/chip/logging/library_handle.py b/src/controller/python/chip/logging/library_handle.py index 5dadeb2cbe4f2b..0ed77f64d89978 100644 --- a/src/controller/python/chip/logging/library_handle.py +++ b/src/controller/python/chip/logging/library_handle.py @@ -16,7 +16,6 @@ import chip.native import ctypes -from ctypes import c_void_p from chip.logging.types import LogRedirectCallback_t @@ -35,6 +34,6 @@ def _GetLoggingLibraryHandle() -> ctypes.CDLL: setter = chip.native.NativeLibraryHandleMethodArguments(handle) setter.Set('pychip_logging_set_callback', - c_void_p, [LogRedirectCallback_t]) + ctypes.c_void_p, [LogRedirectCallback_t]) return handle