From 7c50366f496d8af733dd930fac79757f99765497 Mon Sep 17 00:00:00 2001 From: Chuck Short Date: Mon, 10 Sep 2018 12:30:53 -0400 Subject: [PATCH] Fix pylint warnings for "unnecessary not" Fix boolean expressions that creates an unnecessary negation. Change-Id: Ib17693a426107949488b920a19fa3d13398ee897 Signed-off-by: Chuck Short --- .pylintrc | 1 - cinder/cmd/volume_usage_audit.py | 2 +- cinder/volume/drivers/datera/datera_api2.py | 4 ++-- cinder/volume/drivers/datera/datera_api21.py | 4 ++-- cinder/volume/drivers/hpe/hpe_3par_iscsi.py | 2 +- cinder/volume/drivers/ibm/flashsystem_common.py | 6 +++--- cinder/volume/drivers/ibm/gpfs.py | 4 ++-- cinder/volume/drivers/vmware/vmdk.py | 2 +- 8 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.pylintrc b/.pylintrc index dc887074eca..7ab95b27fac 100644 --- a/.pylintrc +++ b/.pylintrc @@ -144,7 +144,6 @@ disable= unused-variable, len-as-condition, cell-var-from-loop, - unneeded-not, singleton-comparison, misplaced-comparison-constant, unidiomatic-typecheck, diff --git a/cinder/cmd/volume_usage_audit.py b/cinder/cmd/volume_usage_audit.py index 4363d2f2e84..c7e49d1fc22 100644 --- a/cinder/cmd/volume_usage_audit.py +++ b/cinder/cmd/volume_usage_audit.py @@ -81,7 +81,7 @@ def _time_error(LOG, begin, end): "%Y-%m-%d %H:%M:%S") begin = begin.replace(tzinfo=iso8601.UTC) end = end.replace(tzinfo=iso8601.UTC) - if not end > begin: + if end <= begin: msg = _("The end time (%(end)s) must be after the start " "time (%(start)s).") % {'start': begin, 'end': end} diff --git a/cinder/volume/drivers/datera/datera_api2.py b/cinder/volume/drivers/datera/datera_api2.py index fb7e58487c9..23a31d50cce 100644 --- a/cinder/volume/drivers/datera/datera_api2.py +++ b/cinder/volume/drivers/datera/datera_api2.py @@ -675,7 +675,7 @@ class DateraApi(object): TIMEOUT = 10 retry = 0 poll = True - while poll and not retry >= TIMEOUT: + while poll and retry < TIMEOUT: retry += 1 snap = self._issue_api_request(url, api_version='2') if snap['op_state'] == 'available': @@ -695,7 +695,7 @@ class DateraApi(object): policies['default_storage_name']).format( datc._get_name(volume['id'])) poll = True - while poll and not retry >= TIMEOUT: + while poll and retry < TIMEOUT: retry += 1 si = self._issue_api_request(check_url, api_version='2') if si['op_state'] == 'available': diff --git a/cinder/volume/drivers/datera/datera_api21.py b/cinder/volume/drivers/datera/datera_api21.py index db263e80989..80f68490c0b 100644 --- a/cinder/volume/drivers/datera/datera_api21.py +++ b/cinder/volume/drivers/datera/datera_api21.py @@ -800,7 +800,7 @@ class DateraApi(object): TIMEOUT = 20 retry = 0 poll = True - while poll and not retry >= TIMEOUT: + while poll and retry < TIMEOUT: retry += 1 snap = self._issue_api_request(url, api_version='2.1', @@ -822,7 +822,7 @@ class DateraApi(object): policies['default_storage_name']).format( datc._get_name(volume['id'])) poll = True - while poll and not retry >= TIMEOUT: + while poll and retry < TIMEOUT: retry += 1 si = self._issue_api_request(check_url, api_version='2.1', diff --git a/cinder/volume/drivers/hpe/hpe_3par_iscsi.py b/cinder/volume/drivers/hpe/hpe_3par_iscsi.py index df4ccd63b8a..8fe1989970b 100644 --- a/cinder/volume/drivers/hpe/hpe_3par_iscsi.py +++ b/cinder/volume/drivers/hpe/hpe_3par_iscsi.py @@ -199,7 +199,7 @@ class HPE3PARISCSIDriver(hpebasedriver.HPE3PARDriverBase): "target_ip_address '%s.'", (", ".join(temp_iscsi_ip))) - if not len(iscsi_ip_list) > 0: + if not len(iscsi_ip_list): msg = _('At least one valid iSCSI IP address must be set.') LOG.error(msg) raise exception.InvalidInput(reason=msg) diff --git a/cinder/volume/drivers/ibm/flashsystem_common.py b/cinder/volume/drivers/ibm/flashsystem_common.py index 1ac0c30ccc8..4b3618cd9f6 100644 --- a/cinder/volume/drivers/ibm/flashsystem_common.py +++ b/cinder/volume/drivers/ibm/flashsystem_common.py @@ -481,7 +481,7 @@ class FlashSystemDriver(san.SanDriver, # Get storage system name and id ssh_cmd = ['svcinfo', 'lssystem', '-delim', '!'] attributes = self._execute_command_and_parse_attributes(ssh_cmd) - if not attributes or not ('name' in attributes): + if not attributes or ('name' not in attributes): msg = _('Could not get system name.') LOG.error(msg) raise exception.VolumeBackendAPIException(data=msg) @@ -490,7 +490,7 @@ class FlashSystemDriver(san.SanDriver, # Validate value of open_access_enabled flag, for now only # support when open_access_enabled is off - if not attributes or not ('open_access_enabled' in attributes) or ( + if not attributes or ('open_access_enabled' not in attributes) or ( attributes['open_access_enabled'] != 'off'): msg = _('open_access_enabled is not off.') LOG.error(msg) @@ -504,7 +504,7 @@ class FlashSystemDriver(san.SanDriver, msg = _('Unable to parse attributes.') LOG.error(msg) raise exception.InvalidInput(reason=msg) - if not ('status' in attributes) or ( + if ('status' not in attributes) or ( attributes['status'] == 'offline'): msg = (_('Array does not exist or is offline. ' 'Current status of array is %s.') diff --git a/cinder/volume/drivers/ibm/gpfs.py b/cinder/volume/drivers/ibm/gpfs.py index 80d8968a8e6..e363b27fa32 100644 --- a/cinder/volume/drivers/ibm/gpfs.py +++ b/cinder/volume/drivers/ibm/gpfs.py @@ -445,7 +445,7 @@ class GPFSDriver(driver.CloneableImageVD, raise exception.VolumeBackendAPIException(data=msg) _gpfs_cluster_release_level = self._get_gpfs_cluster_release_level() - if not _gpfs_cluster_release_level >= GPFS_CLONE_MIN_RELEASE: + if _gpfs_cluster_release_level < GPFS_CLONE_MIN_RELEASE: msg = (_('Downlevel GPFS Cluster Detected. GPFS Clone feature ' 'not enabled in cluster daemon level %(cur)s - must ' 'be at least at level %(min)s.') % @@ -474,7 +474,7 @@ class GPFSDriver(driver.CloneableImageVD, filesystem, fslevel = \ self._get_gpfs_fs_release_level(directory) - if not fslevel >= GPFS_CLONE_MIN_RELEASE: + if fslevel < GPFS_CLONE_MIN_RELEASE: msg = (_('The GPFS filesystem %(fs)s is not at the required ' 'release level. Current level is %(cur)s, must be ' 'at least %(min)s.') % diff --git a/cinder/volume/drivers/vmware/vmdk.py b/cinder/volume/drivers/vmware/vmdk.py index 78c1c80356e..1b4761726d8 100644 --- a/cinder/volume/drivers/vmware/vmdk.py +++ b/cinder/volume/drivers/vmware/vmdk.py @@ -2008,7 +2008,7 @@ class VMwareVcVmdkDriver(driver.VolumeDriver): host = None rp = None folder = None - if not clone_type == volumeops.LINKED_CLONE_TYPE: + if clone_type != volumeops.LINKED_CLONE_TYPE: # Pick a datastore where to create the full clone under any host (host, rp, folder, summary) = self._select_ds_for_volume(volume) datastore = summary.datastore