From b163ae073ebc34320ce1e250739293920ed29f8c Mon Sep 17 00:00:00 2001 From: junchao Date: Thu, 12 Aug 2021 13:57:06 +0800 Subject: [PATCH] Fix LGTM warning --- platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py | 4 +--- platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py | 2 -- platform/mellanox/mlnx-platform-api/sonic_platform/fan.py | 2 +- platform/mellanox/mlnx-platform-api/sonic_platform/module.py | 2 -- platform/mellanox/mlnx-platform-api/tests/test_eeprom.py | 2 +- platform/mellanox/mlnx-platform-api/tests/test_fan_api.py | 1 - platform/mellanox/mlnx-platform-api/tests/test_psu.py | 1 - platform/mellanox/mlnx-platform-api/tests/test_sfp_event.py | 1 - platform/mellanox/mlnx-platform-api/tests/test_thermal.py | 2 -- 9 files changed, 3 insertions(+), 14 deletions(-) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py b/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py index ee70a28a4ea7..ec3729290236 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py @@ -9,9 +9,7 @@ try: from sonic_platform_base.chassis_base import ChassisBase from sonic_py_common.logger import Logger - import glob import os - import sys from functools import reduce from . import utils @@ -794,7 +792,7 @@ def get_module(self, index): module """ self.initialize_single_module(index) - return super(Chassis, self).get_module(index) + return super(ModularChassis, self).get_module(index) @utils.default_return(-1) def get_module_index(self, module_name): diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py b/platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py index b24a645b2921..decd3a24f409 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py @@ -7,8 +7,6 @@ ############################################################################# import os import subprocess -import time -import subprocess from sonic_py_common.logger import Logger try: diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/fan.py b/platform/mellanox/mlnx-platform-api/sonic_platform/fan.py index 8d607cd087f4..d57aa2395026 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/fan.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/fan.py @@ -12,7 +12,7 @@ try: from sonic_platform_base.fan_base import FanBase from sonic_py_common.logger import Logger - from .led import FanLed, ComponentFaultyIndicator + from .led import ComponentFaultyIndicator from . import utils except ImportError as e: raise ImportError (str(e) + "- required module not found") diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/module.py b/platform/mellanox/mlnx-platform-api/sonic_platform/module.py index 69c915e6fa0d..a02bcb1a9968 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/module.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/module.py @@ -1,6 +1,4 @@ -import os import redis -import sys import threading from sonic_platform_base.module_base import ModuleBase from sonic_py_common.logger import Logger diff --git a/platform/mellanox/mlnx-platform-api/tests/test_eeprom.py b/platform/mellanox/mlnx-platform-api/tests/test_eeprom.py index 82ed0f9589d6..74e3bbf9427e 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_eeprom.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_eeprom.py @@ -35,7 +35,7 @@ def test_chassis_eeprom(self, mock_eeprom_info): def test_eeprom_init(self): # Test symlink not exist, there is an exception with pytest.raises(RuntimeError): - eeprom = Eeprom() + Eeprom() @patch('os.path.exists', MagicMock(return_value=True)) @patch('os.path.islink', MagicMock(return_value=True)) diff --git a/platform/mellanox/mlnx-platform-api/tests/test_fan_api.py b/platform/mellanox/mlnx-platform-api/tests/test_fan_api.py index d0154dfbf3b9..7e9f8140ed3f 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_fan_api.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_fan_api.py @@ -10,7 +10,6 @@ from sonic_platform import utils from sonic_platform.fan import Fan, PsuFan, COOLING_STATE_PATH -from sonic_platform.led import FanLed from sonic_platform.fan_drawer import RealDrawer, VirtualDrawer from sonic_platform.psu import Psu diff --git a/platform/mellanox/mlnx-platform-api/tests/test_psu.py b/platform/mellanox/mlnx-platform-api/tests/test_psu.py index ea9a8ffbce38..84f3f5fda769 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_psu.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_psu.py @@ -11,7 +11,6 @@ from sonic_platform import utils from sonic_platform.psu import FixedPsu, Psu -from sonic_platform.device_data import DeviceDataManager class TestPsu: diff --git a/platform/mellanox/mlnx-platform-api/tests/test_sfp_event.py b/platform/mellanox/mlnx-platform-api/tests/test_sfp_event.py index c6c5b1973a6e..186a25f6d568 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_sfp_event.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_sfp_event.py @@ -1,5 +1,4 @@ import os -import select import sys from mock import MagicMock, patch diff --git a/platform/mellanox/mlnx-platform-api/tests/test_thermal.py b/platform/mellanox/mlnx-platform-api/tests/test_thermal.py index d8889f5b9848..6a7b6deabbce 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_thermal.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_thermal.py @@ -1,7 +1,5 @@ import glob import os -import pytest -import shutil import sys if sys.version_info.major == 3: from unittest import mock