Skip to content

Commit

Permalink
Fix more Python warnings (#869)
Browse files Browse the repository at this point in the history
* Fix "First parameter of a method is not named 'self'" warnings

* Fix "Module is imported with 'import' and 'import from'" warning

* Fix 'Testing equality to None' warnings

* Clean up 'Unused import' warnings
  • Loading branch information
jleveque committed Apr 8, 2020
1 parent 79eb63e commit a0f3b93
Show file tree
Hide file tree
Showing 47 changed files with 14 additions and 133 deletions.
1 change: 0 additions & 1 deletion config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import sys
import os
import click
import json
import subprocess
import netaddr
import re
Expand Down
4 changes: 0 additions & 4 deletions config/mlnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@
import os
import subprocess
import click
import imp
import syslog
import types
import traceback
import time
from tabulate import tabulate
except ImportError as e:
raise ImportError("%s - required module not found" % str(e))

Expand Down
2 changes: 0 additions & 2 deletions config/nat.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python

import click
import socket
import netaddr
import ipaddress
from swsssdk import ConfigDBConnector
from swsssdk import SonicV2Connector
Expand Down
3 changes: 0 additions & 3 deletions connect/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#! /usr/bin/python -u

import click
import errno
import os
import pexpect
import subprocess
import sys
from click_default_group import DefaultGroup

try:
Expand Down
1 change: 0 additions & 1 deletion consutil/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
try:
import click
import re
import swsssdk
import subprocess
import sys
except ImportError as e:
Expand Down
2 changes: 0 additions & 2 deletions consutil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import click
import os
import pexpect
import re
import subprocess
import sys
from tabulate import tabulate
from lib import *
Expand Down
1 change: 0 additions & 1 deletion crm/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python

import os
import click
import swsssdk
from tabulate import tabulate
Expand Down
2 changes: 0 additions & 2 deletions debug/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
# date: 07/12/17

import click
import os
import subprocess
from click_default_group import DefaultGroup
from pprint import pprint

def run_command(command, pager=False):
click.echo(click.style("Command: ", fg='cyan') + click.style(command, fg='green'))
Expand Down
7 changes: 0 additions & 7 deletions pddf_fanutil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,8 @@
try:
import sys
import os
import subprocess
import click
import imp
import syslog
import types
import traceback
from tabulate import tabulate
from utilities_common import util_base
from utilities_common.util_base import UtilLogger
from utilities_common.util_base import UtilHelper
except ImportError as e:
raise ImportError("%s - required module not found" % str(e))
Expand Down
8 changes: 0 additions & 8 deletions pddf_ledutil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,7 @@
try:
import sys
import os
import subprocess
import click
import imp
import syslog
import types
import traceback
from tabulate import tabulate
from utilities_common import util_base
from utilities_common.util_base import UtilLogger
from utilities_common.util_base import UtilHelper
except ImportError as e:
raise ImportError("%s - required module not found" % str(e))
Expand Down
7 changes: 0 additions & 7 deletions pddf_psuutil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,8 @@
try:
import sys
import os
import subprocess
import click
import imp
import syslog
import types
import traceback
from tabulate import tabulate
from utilities_common import util_base
from utilities_common.util_base import UtilLogger
from utilities_common.util_base import UtilHelper
except ImportError as e:
raise ImportError("%s - required module not found" % str(e))
Expand Down
7 changes: 0 additions & 7 deletions pddf_thermalutil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,8 @@
try:
import sys
import os
import subprocess
import click
import imp
import syslog
import types
import traceback
from tabulate import tabulate
from utilities_common import util_base
from utilities_common.util_base import UtilLogger
from utilities_common.util_base import UtilHelper
except ImportError as e:
raise ImportError("%s - required module not found" % str(e))
Expand Down
3 changes: 1 addition & 2 deletions pfc/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python

import os
import click
import swsssdk
from tabulate import tabulate
Expand Down Expand Up @@ -160,4 +159,4 @@ def showPrio(interface):
config.add_command(configAsym, "asymmetric")
config.add_command(configPrio, "priority")
show.add_command(showAsym, "asymmetric")
show.add_command(showPrio, "priority")
show.add_command(showPrio, "priority")
2 changes: 0 additions & 2 deletions psuutil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import click
import imp
import syslog
import types
import traceback
from tabulate import tabulate
except ImportError as e:
raise ImportError("%s - required module not found" % str(e))
Expand Down
3 changes: 0 additions & 3 deletions scripts/aclshow
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@ from __future__ import print_function
import argparse
import json
import os
import re
import subprocess
import swsssdk
import sys

from tabulate import tabulate
from natsort import natsorted

### temp file to save counter positions when doing clear counter action.
### if we could have a SAI command to clear counters will be better, so no need to maintain
Expand Down
4 changes: 0 additions & 4 deletions scripts/configlet
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,9 @@ A sample for update:
"""

from __future__ import print_function
import sys
import os.path
import argparse
import json
import time
from collections import OrderedDict
from natsort import natsorted
from swsssdk import ConfigDBConnector

test_only = False
Expand Down
3 changes: 0 additions & 3 deletions scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
import syslog
from swsssdk import ConfigDBConnector
import sonic_device_util
import os
import subprocess
import json


SYSLOG_IDENTIFIER = 'db_migrator'
Expand Down
8 changes: 1 addition & 7 deletions scripts/decode-syseeprom
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@
# This is the main script that handles eeprom encoding and decoding
#
try:
import exceptions
import binascii
import time
import optparse
import warnings
import os
import subprocess
import sys
from array import array
import imp
from sonic_eeprom import eeprom_dts
import glob
from sonic_device_util import get_machine_info
from sonic_device_util import get_platform_info
Expand Down Expand Up @@ -55,7 +49,7 @@ def main():
# Currently, don't support eeprom db on Arista platform
platforms_without_eeprom_db = ['arista', 'kvm']
if any(platform in platform_path for platform in platforms_without_eeprom_db)\
or getattr(t, 'read_eeprom_db', None) == None:
or getattr(t, 'read_eeprom_db', None) is None:
support_eeprom_db = False

#
Expand Down
1 change: 0 additions & 1 deletion scripts/dump_nat_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
so as to restore them during warm reboot
"""

import sys
import subprocess

def main():
Expand Down
1 change: 0 additions & 1 deletion scripts/ecnconfig
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ from __future__ import print_function

import os
import sys
import json
import argparse
import swsssdk
from tabulate import tabulate
Expand Down
2 changes: 0 additions & 2 deletions scripts/fanshow
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"""
from __future__ import print_function

import argparse

from tabulate import tabulate
from swsssdk import SonicV2Connector
from natsort import natsorted
Expand Down
4 changes: 1 addition & 3 deletions scripts/fdbclear
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import argparse
import json
import sys

from natsort import natsorted
from swsssdk import SonicV2Connector, port_util
from tabulate import tabulate
from swsssdk import SonicV2Connector

class FdbClear(object):

Expand Down
4 changes: 0 additions & 4 deletions scripts/intfstat
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
import argparse
import cPickle as pickle
import datetime
import getopt
import sys
import os
import json
import re
import subprocess
import swsssdk
import sys
import time
Expand Down
3 changes: 0 additions & 3 deletions scripts/natclear
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@
import argparse
import json
import sys
import subprocess

from natsort import natsorted
from swsssdk import SonicV2Connector
from tabulate import tabulate

class NatClear(object):

Expand Down
2 changes: 0 additions & 2 deletions scripts/natconfig
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@
"""

import argparse
import json
import sys

from natsort import natsorted
from tabulate import tabulate
from swsssdk import ConfigDBConnector

Expand Down
1 change: 0 additions & 1 deletion scripts/natshow
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ import json
import sys
import re

from natsort import natsorted
from swsssdk import SonicV2Connector
from tabulate import tabulate

Expand Down
2 changes: 0 additions & 2 deletions scripts/neighbor_advertiser
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import traceback
import subprocess
import time
import warnings
import sonic_device_util
from swsssdk import ConfigDBConnector
from swsssdk import SonicV2Connector
from netaddr import IPAddress, IPNetwork


Expand Down
3 changes: 0 additions & 3 deletions scripts/pfcstat
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import sys
import argparse
import cPickle as pickle
import datetime
import getopt
import json
import os.path
import time

from collections import namedtuple, OrderedDict
from natsort import natsorted
Expand Down
2 changes: 0 additions & 2 deletions scripts/portconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ optional arguments:
"""
from __future__ import print_function

import os
import sys
import json
import argparse
import swsssdk

Expand Down
3 changes: 0 additions & 3 deletions scripts/portstat
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
import argparse
import cPickle as pickle
import datetime
import getopt
import os.path
import re
import subprocess
import swsssdk
import sys
import time
Expand Down
2 changes: 0 additions & 2 deletions scripts/queuestat
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import argparse
import cPickle as pickle
import datetime
import getopt
import json
import os.path
import swsssdk
import sys
Expand Down
4 changes: 1 addition & 3 deletions scripts/sfpshow
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
Script to show sfp eeprom and presence status.
Not like sfputil this scripts get the sfp data from DB directly.
"""
import argparse
import json
import sys
import click
import re
import operator
import os

from natsort import natsorted
from swsssdk import SonicV2Connector, port_util
from swsssdk import SonicV2Connector
from tabulate import tabulate

# Mock the redis for unit test purposes #
Expand Down

0 comments on commit a0f3b93

Please sign in to comment.