From 44576014414bd8891539fea644dd4eb02408d4ec Mon Sep 17 00:00:00 2001 From: Taras Drozdovskyi Date: Fri, 26 Nov 2021 18:00:52 +0200 Subject: [PATCH] Fix some alerts founded the LGTM system (#11966) Signed-off-by: Taras Drozdovskyi --- scripts/build/builders/mbed.py | 4 ---- scripts/tools/memory/memdf/df.py | 3 ++- scripts/tools/memory/report_summary.py | 2 -- src/controller/python/chip-repl.py | 8 -------- src/controller/python/chip/ChipDeviceCtrl.py | 4 ++-- src/controller/python/chip/ChipReplStartup.py | 3 +-- src/controller/python/chip/clusters/Attribute.py | 4 ++-- src/controller/python/chip/clusters/Command.py | 2 +- src/controller/python/chip/interaction_model/__init__.py | 2 +- 9 files changed, 9 insertions(+), 23 deletions(-) diff --git a/scripts/build/builders/mbed.py b/scripts/build/builders/mbed.py index d0198ca0c032e1..5ba45d136eb174 100644 --- a/scripts/build/builders/mbed.py +++ b/scripts/build/builders/mbed.py @@ -12,12 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging import os -import platform -import glob import shlex -import pathlib from enum import Enum, auto from .builder import Builder diff --git a/scripts/tools/memory/memdf/df.py b/scripts/tools/memory/memdf/df.py index a91e44c669d94b..7345f41e0163a6 100644 --- a/scripts/tools/memory/memdf/df.py +++ b/scripts/tools/memory/memdf/df.py @@ -32,7 +32,8 @@ def __init__(self, *args, **kwargs): self[c] = pd.Series() types = {c: self.dtype[c] for c in self.columns if c in self.dtype} typed_columns = list(types.keys()) - self[typed_columns] = self.astype(types, copy=False)[typed_columns] + self[typed_columns] = self.astype(types, copy=False)[ + typed_columns] # lgtm [py/hash-unhashable-value] self.attrs['name'] = self.name diff --git a/scripts/tools/memory/report_summary.py b/scripts/tools/memory/report_summary.py index 3b21f6a88bb8ea..5a3d0cd4ded8d0 100755 --- a/scripts/tools/memory/report_summary.py +++ b/scripts/tools/memory/report_summary.py @@ -28,8 +28,6 @@ import sys -import numpy # type: ignore - import memdf.collect import memdf.report import memdf.select diff --git a/src/controller/python/chip-repl.py b/src/controller/python/chip-repl.py index 0f6798137e4d06..49adafca317bb8 100755 --- a/src/controller/python/chip-repl.py +++ b/src/controller/python/chip-repl.py @@ -18,15 +18,7 @@ # import IPython -import chip -import chip.logging -import coloredlogs -import logging from traitlets.config import Config -from rich import print -from rich import pretty -from rich import inspect -import builtins import argparse import sys diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index 4ca3aa94bbd0da..e093442043bcc1 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -346,11 +346,11 @@ def DeviceAvailableCallback(device, err): # The callback might have been received synchronously (during self._ChipStack.Call()). # Check if the device is already set before waiting for the callback. - if returnDevice.value == None: + if returnDevice.value is None: with deviceAvailableCV: deviceAvailableCV.wait() - if returnDevice.value == None: + if returnDevice.value is None: raise self._ChipStack.ErrorToException(CHIP_ERROR_INTERNAL) return returnDevice diff --git a/src/controller/python/chip/ChipReplStartup.py b/src/controller/python/chip/ChipReplStartup.py index 865042e34315be..8d032b9b356bdc 100644 --- a/src/controller/python/chip/ChipReplStartup.py +++ b/src/controller/python/chip/ChipReplStartup.py @@ -8,7 +8,6 @@ import chip.clusters as Clusters import coloredlogs import chip.logging -import argparse import builtins @@ -41,7 +40,7 @@ def ReplInit(): def matterhelp(classOrObj=None): - if (classOrObj == None): + if (classOrObj is None): inspect(builtins.devCtrl, methods=True, help=True, private=False) else: inspect(classOrObj, methods=True, help=True, private=False) diff --git a/src/controller/python/chip/clusters/Attribute.py b/src/controller/python/chip/clusters/Attribute.py index d8f3cebe68bc0c..fd39b3ca987cc4 100644 --- a/src/controller/python/chip/clusters/Attribute.py +++ b/src/controller/python/chip/clusters/Attribute.py @@ -18,8 +18,8 @@ from asyncio.futures import Future import ctypes from dataclasses import dataclass -from typing import Type, Union, List, Any -from ctypes import CFUNCTYPE, c_char_p, c_size_t, c_void_p, c_uint32, c_uint16, py_object +from typing import Union, List, Any +from ctypes import CFUNCTYPE, c_char_p, c_size_t, c_uint32, c_uint16, py_object from .ClusterObjects import ClusterAttributeDescriptor import chip.exceptions diff --git a/src/controller/python/chip/clusters/Command.py b/src/controller/python/chip/clusters/Command.py index 179c4ed9959da1..e097184297b518 100644 --- a/src/controller/python/chip/clusters/Command.py +++ b/src/controller/python/chip/clusters/Command.py @@ -74,7 +74,7 @@ def _handleResponse(self, path: CommandPath, status: Status, response: bytes): self._future.set_result(None) else: # If a type hasn't been assigned, let's auto-deduce it. - if (self._expect_type == None): + if (self._expect_type is None): self._expect_type = FindCommandClusterObject(False, path) if self._expect_type: diff --git a/src/controller/python/chip/interaction_model/__init__.py b/src/controller/python/chip/interaction_model/__init__.py index 0ef2d861c18fc8..2b4bef9145a0e8 100644 --- a/src/controller/python/chip/interaction_model/__init__.py +++ b/src/controller/python/chip/interaction_model/__init__.py @@ -26,7 +26,7 @@ from chip.exceptions import ChipStackException -__all__ = ["IMDelegate", "Status", "InteractionModelError"] +__all__ = ["Status", "InteractionModelError"] class Status(enum.IntEnum):