Browse Source

F841 local variable 'X' is assigned to but never used

un-suppress the flake8 error check for F841,
and update the code to fix that error

Test Plan:
PASS: system drbdsync-modify --util 41

Story: 2008943
Task: 44099

Signed-off-by: Jia Hu <jia.hu@windriver.com>
Change-Id: I8654b23489e9574ee935c66df0054bdc589a4cdb
changes/19/820219/4
Jia Hu 8 months ago
parent
commit
3c838b033e
  1. 2
      sysinv/cgts-client/cgts-client/cgtsclient/common/utils.py
  2. 2
      sysinv/cgts-client/cgts-client/cgtsclient/exc.py
  3. 2
      sysinv/cgts-client/cgts-client/cgtsclient/shell.py
  4. 7
      sysinv/cgts-client/cgts-client/cgtsclient/v1/drbdconfig_shell.py
  5. 1
      sysinv/cgts-client/cgts-client/cgtsclient/v1/host_fs.py
  6. 2
      sysinv/cgts-client/cgts-client/cgtsclient/v1/idisk_shell.py
  7. 2
      sysinv/cgts-client/cgts-client/cgtsclient/v1/isensorgroup_shell.py
  8. 1
      sysinv/cgts-client/cgts-client/cgtsclient/v1/ptp_shell.py
  9. 4
      sysinv/cgts-client/cgts-client/cgtsclient/v1/sm_service_shell.py
  10. 4
      sysinv/cgts-client/cgts-client/tox.ini

2
sysinv/cgts-client/cgts-client/cgtsclient/common/utils.py

@ -74,7 +74,7 @@ def _wrapping_formatter_callback_decorator(subparser, command, callback):
try:
subparser.add_argument('--nowrap', action='store_true',
help='No wordwrapping of output')
except Exception as e:
except Exception:
# exception happens when nowrap option already configured
# for command - so get out with callback undecorated
return callback

2
sysinv/cgts-client/cgts-client/cgtsclient/exc.py

@ -199,7 +199,7 @@ class CgtsclientException(Exception):
try:
message = self.message % kwargs # pylint: disable=exception-message-attribute
except Exception as e:
except Exception:
# kwargs doesn't match a variable in the message
# at least get the core message out if something happened
message = self.message # pylint: disable=exception-message-attribute

2
sysinv/cgts-client/cgts-client/cgtsclient/shell.py

@ -346,7 +346,7 @@ def main():
print(('caught: %r, aborting' % (e)), file=sys.stderr)
sys.exit(0)
except IOError as e:
except IOError:
sys.exit(0)
except Exception as e:

7
sysinv/cgts-client/cgts-client/cgtsclient/v1/drbdconfig_shell.py

@ -46,7 +46,7 @@ def do_drbdsync_show(cc, args):
_print_drbdsync_show(drbdconfigs[0])
print('')
ihosts = cc.ihost.list_personality(personality=CONTROLLER)
ihosts = cc.ihost.list_personality(CONTROLLER)
_print_controller_config_show(ihosts)
@ -84,9 +84,8 @@ def do_drbdsync_modify(cc, args):
% pa['path'][1:])
# Prevent update if controllers are mid-configuration
personality = 'controller'
is_config = False
ihosts = cc.ihost.list_personality(personality=CONTROLLER)
ihosts = cc.ihost.list_personality(CONTROLLER)
for ihost in ihosts:
if ihost.config_target and ihost.config_applied != ihost.config_target:
is_config = True
@ -108,7 +107,7 @@ def do_drbdsync_modify(cc, args):
do_wait = True
LOOP_MAX = int(configuration_timeout // wait_interval)
for x in range(0, LOOP_MAX):
ihosts = cc.ihost.list_personality(personality=CONTROLLER)
ihosts = cc.ihost.list_personality(CONTROLLER)
do_wait = False
hosts = []
for ihost in ihosts:

1
sysinv/cgts-client/cgts-client/cgtsclient/v1/host_fs.py

@ -49,7 +49,6 @@ class HostFsManager(base.Manager):
def create(self, **kwargs):
path = '/v1/host_fs'
valid_list = []
new = {}
for (key, value) in kwargs.items():
if key in CREATION_ATTRIBUTES:

2
sysinv/cgts-client/cgts-client/cgtsclient/v1/idisk_shell.py

@ -138,7 +138,7 @@ def do_host_disk_wipe(cc, args):
patch.append({'op': 'replace', 'path': '/' + k, 'value': v})
try:
updated_idisk = cc.idisk.update(idisk.uuid, patch)
cc.idisk.update(idisk.uuid, patch)
except exc.HTTPNotFound:
raise exc.CommandError(
"ERROR: Failed to wipe and GPT format disk %s "

2
sysinv/cgts-client/cgts-client/cgtsclient/v1/isensorgroup_shell.py

@ -182,7 +182,7 @@ def do_host_sensorgroup_relearn(cc, args):
ihost = ihost_utils._find_ihost(cc, args.hostnameorid)
isensorgroups = cc.isensorgroup.relearn(ihost.uuid)
cc.isensorgroup.relearn(ihost.uuid)
print("%s sensor model and any related alarm assertions are being "
"deleted." % (args.hostnameorid))

1
sysinv/cgts-client/cgts-client/cgtsclient/v1/ptp_shell.py

@ -52,7 +52,6 @@ def do_ptp_modify(cc, args):
ptps = cc.ptp.list()
ptp = ptps[0]
op = "replace"
attributes = []

4
sysinv/cgts-client/cgts-client/cgtsclient/v1/sm_service_shell.py

@ -77,7 +77,7 @@ def do_service_enable(cc, args):
patch = utils.dict_to_patch(values)
try:
response = cc.sm_service.update(args.service, patch)
cc.sm_service.update(args.service, patch)
except exc.HTTPNotFound:
raise exc.CommandError('service not recognized: %s' % args.service)
except exc.Forbidden:
@ -91,7 +91,7 @@ def do_service_disable(cc, args):
values = {'enabled': False}
patch = utils.dict_to_patch(values)
try:
response = cc.sm_service.update(args.service, patch)
cc.sm_service.update(args.service, patch)
except exc.HTTPNotFound:
raise exc.CommandError('service not recognized: %s' % args.service)
except exc.Forbidden:

4
sysinv/cgts-client/cgts-client/tox.ini

@ -111,12 +111,10 @@ max-complexity=25
# E501 line too long
# E731 do not assign a lambda expression, use a def
# -F- codes are errors
# F841 local variable 'X' is assigned to but never used
ignore = H102,H104,H105,H238,H404,H405,
B004,B005,B006,B009,B010,
W503,W504,W605,
E501,E731,
F841
E501,E731
[testenv:pylint]
basepython = python3

Loading…
Cancel
Save