Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply some recommendations from the LGTM system #10773

Merged
merged 1 commit into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion scripts/build/builders/infineon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions scripts/examples/gn_to_cmakelists.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "')
Expand Down
1 change: 0 additions & 1 deletion scripts/flashing/nrfconnect_firmware_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
1 change: 0 additions & 1 deletion scripts/tools/memory/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/tools/memory/report_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import sys

import numpy as np # type: ignore
import numpy # type: ignore

import memdf.collect
import memdf.report
Expand Down
5 changes: 1 addition & 4 deletions src/controller/python/chip-device-ctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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)
Expand All @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions src/controller/python/chip/ChipDeviceCtrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/controller/python/chip/clusters/Command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/controller/python/chip/clusters/TestObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/controller/python/chip/discovery/library_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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])

Expand Down
8 changes: 4 additions & 4 deletions src/controller/python/chip/internal/commissioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
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])
Expand Down
3 changes: 1 addition & 2 deletions src/controller/python/chip/logging/library_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import chip.native
import ctypes
from ctypes import c_void_p
from chip.logging.types import LogRedirectCallback_t


Expand All @@ -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