pylint fixes: remove redundant parens, fix comparison order 77/27577/3
authorRoss Brattain <ross.b.brattain@intel.com>
Thu, 26 Jan 2017 00:15:52 +0000 (16:15 -0800)
committerRoss Brattain <ross.b.brattain@intel.com>
Wed, 8 Feb 2017 06:51:04 +0000 (06:51 +0000)
removed redundant parens in if and while clauses
use var != constant, not constant != var.
Python doesn't allow for assignment in if statements, so we don't have
to use the old C workarounds

remove unwanted commas
use raw strings for regexps with backslashes, e.g. r'\s' instead of '\s'

Change-Id: I7aad645dd3d7f4b4b62f4e4510a425611c9d28f2
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
api/resources/env_action.py
api/utils/common.py
api/utils/influx.py
yardstick/benchmark/core/__init__.py
yardstick/benchmark/runners/arithmetic.py
yardstick/benchmark/scenarios/networking/sfc_openstack.py
yardstick/common/task_template.py

index 8955f3c..917681c 100644 (file)
@@ -248,7 +248,7 @@ def _get_remote_rc_file(rc_file, installer_ip, installer_type):
         cmd = [os_fetch_script, '-d', rc_file, '-i', installer_type,
                '-a', installer_ip]
         p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
-        p.communicate()[0]
+        p.communicate()
 
         if p.returncode != 0:
             logger.debug('Failed to fetch credentials from installer')
index 1c800ce..3e9bf8f 100644 (file)
@@ -33,7 +33,7 @@ def get_command_list(command_list, opts, args):
 
     command_list.append(args)
 
-    command_list.extend(('--{}'.format(k) for k in opts if 'task-args' != k))
+    command_list.extend(('--{}'.format(k) for k in opts if k != 'task-args'))
 
     task_args = opts.get('task-args', '')
     if task_args:
index 275c63a..08996b9 100644 (file)
@@ -24,7 +24,7 @@ def get_data_db_client():
     try:
         parser.read(conf.OUTPUT_CONFIG_FILE_PATH)
 
-        if 'influxdb' != parser.get('DEFAULT', 'dispatcher'):
+        if parser.get('DEFAULT', 'dispatcher') != 'influxdb':
             raise RuntimeError
 
         return _get_client(parser)
index 161e448..79ebc73 100644 (file)
@@ -33,6 +33,6 @@ class Param(object):
 
 def print_hbar(barlen):
     """print to stdout a horizontal bar"""
-    print("+"),
-    print("-" * barlen),
+    print("+")
+    print("-" * barlen)
     print("+")
index d5605f7..65fdb9d 100755 (executable)
@@ -139,7 +139,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg,
 
         sequence += 1
 
-        if (errors and sla_action is None):
+        if errors and sla_action is None:
             break
 
     benchmark.teardown()
index caaf100..be24add 100644 (file)
@@ -81,7 +81,7 @@ def create_floating_ips(neutron_client):  # pragma: no cover
     ips = []
     props = {'floating_network_id': extnet_id}
     try:
-        while (len(ips) < 2):
+        while len(ips) < 2:
             ip_json = neutron_client.create_floatingip({'floatingip': props})
             fip_addr = ip_json['floatingip']['floating_ip_address']
             ips.append(fip_addr)
index bda8a1b..9acc213 100755 (executable)
@@ -45,11 +45,11 @@ def is_really_missing(mis, task_template):
     # Removing variables that have default values from
     # missing. Construction that won't be properly
     # check is {% set x = x or 1}
-    if re.search(mis.join(["{%\s*set\s+", "\s*=\s*", "[^\w]+"]),
+    if re.search(mis.join([r"{%\s*set\s+", "\s*=\s*", r"[^\w]+"]),
                  task_template):
         return False
     # Also check for a default filter which can show up as
     # a missing variable
-    if re.search(mis + "\s*\|\s*default\(", task_template):
+    if re.search(mis + r"\s*\|\s*default\(", task_template):
         return False
     return True