aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiroslav Los <miroslav.los@pantheon.tech>2019-08-14 17:29:33 +0200
committerMiroslav Los <miroslav.los@pantheon.tech>2019-08-14 17:29:33 +0200
commit669d320bc64e41f879c047a39a66b8ec99bf4b1e (patch)
tree969f5240ed44dc38bcc3de55f6f3c51675c08f75
parent37a9451377f7239365b5af778b8072d1585a2d2a (diff)
DO_NOT_MERGE CSIT-1194 - Framework easy pylint improvements
- force a python2 environment in tox for pylint - let pylint load some compiled modules for member checking - allow locally enabled pylint rules - ignore bad enum names - ignore complexity for code to be refactored by other tickets - broad excepts are acceptable sometimes Signed-off-by: Miroslav Los <miroslav.los@pantheon.tech> Change-Id: If4c3a1b85e8609f074e1de8ce91fc9c4fedbeb38
-rw-r--r--pylint.cfg6
-rw-r--r--resources/libraries/python/DropRateSearch.py2
-rw-r--r--resources/libraries/python/GBP.py4
-rw-r--r--resources/libraries/python/IPUtil.py2
-rw-r--r--resources/libraries/python/InterfaceUtil.py2
-rw-r--r--resources/libraries/python/PapiExecutor.py3
-rw-r--r--resources/libraries/python/TrafficGenerator.py8
-rw-r--r--resources/libraries/python/VatExecutor.py9
-rw-r--r--tox.ini1
9 files changed, 22 insertions, 15 deletions
diff --git a/pylint.cfg b/pylint.cfg
index 82c19ae5f9..69668ed79c 100644
--- a/pylint.cfg
+++ b/pylint.cfg
@@ -21,6 +21,10 @@ persistent=yes
# usually to register additional checkers.
load-plugins=
+# A comma-separated list of package or module names from where C extensions may
+# be loaded. Extensions are loading into the active Python interpreter and may
+# run arbitrary code
+extension-pkg-whitelist=numpy, scipy
[MESSAGES CONTROL]
@@ -38,7 +42,7 @@ load-plugins=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
-disable=redefined-variable-type, locally-disabled
+disable=redefined-variable-type, locally-disabled, locally-enabled
[REPORTS]
diff --git a/resources/libraries/python/DropRateSearch.py b/resources/libraries/python/DropRateSearch.py
index e87ef95434..0c4f2c6c02 100644
--- a/resources/libraries/python/DropRateSearch.py
+++ b/resources/libraries/python/DropRateSearch.py
@@ -61,6 +61,8 @@ class SearchResultType(Enum):
class DropRateSearch(object):
"""Abstract class with search algorithm implementation."""
+ #TODO DropRateSearch should be refactored as part of CSIT-1378
+ #pylint: disable=too-many-instance-attributes
__metaclass__ = ABCMeta
diff --git a/resources/libraries/python/GBP.py b/resources/libraries/python/GBP.py
index ff0c133934..e0fa07e9c9 100644
--- a/resources/libraries/python/GBP.py
+++ b/resources/libraries/python/GBP.py
@@ -42,8 +42,8 @@ class GBPBridgeDomainFlags(IntEnum):
class GBPSubnetType(IntEnum):
"""GBP Subnet Type."""
GBP_API_SUBNET_TRANSPORT = 1
- GBP_API_SUBNET_STITCHED_INTERNAL = 2
- GBP_API_SUBNET_STITCHED_EXTERNAL = 3
+ GBP_API_SUBNET_STITCHED_INTERNAL = 2 # pylint: disable=invalid-name
+ GBP_API_SUBNET_STITCHED_EXTERNAL = 3 # pylint: disable=invalid-name
GBP_API_SUBNET_L3_OUT = 4
GBP_API_SUBNET_ANON_L3_OUT = 5
diff --git a/resources/libraries/python/IPUtil.py b/resources/libraries/python/IPUtil.py
index 901d2ed7f7..2109997e99 100644
--- a/resources/libraries/python/IPUtil.py
+++ b/resources/libraries/python/IPUtil.py
@@ -55,7 +55,7 @@ class FibPathType(IntEnum):
class FibPathFlags(IntEnum):
"""FIB path flags."""
FIB_PATH_FLAG_NONE = 0
- FIB_PATH_FLAG_RESOLVE_VIA_ATTACHED = 1
+ FIB_PATH_FLAG_RESOLVE_VIA_ATTACHED = 1 #pylint: disable=invalid-name
FIB_PATH_FLAG_RESOLVE_VIA_HOST = 2
diff --git a/resources/libraries/python/InterfaceUtil.py b/resources/libraries/python/InterfaceUtil.py
index 1f79d7e679..1a97130a8e 100644
--- a/resources/libraries/python/InterfaceUtil.py
+++ b/resources/libraries/python/InterfaceUtil.py
@@ -32,7 +32,7 @@ from resources.libraries.python.VPPUtil import VPPUtil
class LinkBondLoadBalance(IntEnum):
"""Link bonding load balance."""
- L2 = 0
+ L2 = 0 # pylint: disable=invalid-name
L34 = 1
L23 = 2
diff --git a/resources/libraries/python/PapiExecutor.py b/resources/libraries/python/PapiExecutor.py
index 4e4e0828b0..bfa538fc15 100644
--- a/resources/libraries/python/PapiExecutor.py
+++ b/resources/libraries/python/PapiExecutor.py
@@ -193,6 +193,7 @@ class PapiSocketExecutor(object):
# Package path has to be one level above the vpp_papi directory.
package_path = package_path.rsplit('/', 1)[0]
sys.path.append(package_path)
+ # pylint: disable=import-error
from vpp_papi.vpp_papi import VPPApiClient as vpp_class
vpp_class.apidir = api_json_directory
# We need to create instance before removing from sys.path.
@@ -705,7 +706,7 @@ class PapiExecutor(object):
"\n{apis}".format(host=self._node["host"],
apis=api_data))
raise
- except Exception as exc:
+ except Exception as exc: # pylint: disable=broad-except
raise_from(RuntimeError(
"PAPI command(s) execution on host {host} "
"failed: {apis}".format(
diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py
index 334e299f3e..cc968f8e09 100644
--- a/resources/libraries/python/TrafficGenerator.py
+++ b/resources/libraries/python/TrafficGenerator.py
@@ -443,10 +443,10 @@ class TrafficGenerator(AbstractMeasurer):
# we need to encode them, so that repr() does not lead with 'u'.
if isinstance(rate, unicode):
rate = rate.encode("utf-8")
- if isinstance(duration, unicode):
- duration = duration.encode("utf-8")
- if isinstance(warmup_time, unicode):
- warmup_time = warmup_time.encode("utf-8")
+ if not isinstance(duration, (float, int)):
+ duration = float(duration)
+ if not isinstance(warmup_time, (float, int)):
+ warmup_time = float(warmup_time)
command = (
"sh -c '{tool}/resources/tools/trex/trex_stateless_profile.py"
" --profile {prof}/resources/traffic_profiles/trex/{traffic}.py"
diff --git a/resources/libraries/python/VatExecutor.py b/resources/libraries/python/VatExecutor.py
index 8197b5eae9..1d0a2133c0 100644
--- a/resources/libraries/python/VatExecutor.py
+++ b/resources/libraries/python/VatExecutor.py
@@ -252,7 +252,7 @@ class VatTerminal(object):
self._tty,
'sudo -S {0}{1}'.format(Constants.VAT_BIN_NAME, json_text),
self.__VAT_PROMPT)
- except Exception:
+ except Exception: #pylint: disable=broad-except
continue
else:
break
@@ -306,10 +306,9 @@ class VatTerminal(object):
raise RuntimeError("More instances of VPP running on node "
"{0}. VAT command {1} execution failed.".
format(self._node['host'], cmd))
- else:
- raise RuntimeError("VPP not running on node {0}. VAT command "
- "{1} execution failed.".
- format(self._node['host'], cmd))
+ raise RuntimeError("VPP not running on node {0}. VAT command "
+ "{1} execution failed.".
+ format(self._node['host'], cmd))
logger.debug("VAT output: {0}".format(out))
if self.json:
diff --git a/tox.ini b/tox.ini
index fd0a6cf8cd..2aa18779b0 100644
--- a/tox.ini
+++ b/tox.ini
@@ -34,6 +34,7 @@ checker_dir = ./resources/libraries/bash/entry/check
# TODO: Tox prints various warnings. Figure them out and fix them.
[testenv:pylint]
+basepython = python2
deps =
pylint==1.5.4
-r ./requirements.txt