Cleanup pep8 un-used variable warnings

Enable F841 flake8 check 'variables assigned but unused'.

This primarily involved removing the variable or renaming
it as '_' to indicate it is an unused variable.

There should be no runtime difference from these changes.

Test Plan:
  PASS: tox
  PASS: sw-manager strategy creation (CLI commands)

Story: 2010531
Task: 47606
Signed-off-by: Al Bailey <al.bailey@windriver.com>
Change-Id: I2431fe0c0ec7d6e01ab72668efc20c9c5e77e88f
This commit is contained in:
Al Bailey 2023-03-07 17:12:43 +00:00
parent 39238b4467
commit 6f68610806
11 changed files with 31 additions and 35 deletions

View File

@ -33,7 +33,8 @@ def get_token(auth_uri, project_name, project_domain_name, username, password,
Ask OpenStack for a token
"""
try:
request_url = urllib.request.urlopen(auth_uri)
# handle auth_uri re-direct (300)
urllib.request.urlopen(auth_uri)
except urllib.error.HTTPError as e:
if e.code == 300:
auth_uri = e.headers['location']

View File

@ -210,7 +210,7 @@ def setup_fw_update_parser(commands):
# define the create command
# alarm restrictions, defaults to strict
create_strategy_cmd = setup_create_cmd(
_ = setup_create_cmd(
sub_cmds,
[sw_update.APPLY_TYPE_IGNORE], # controller supports ignore
[sw_update.APPLY_TYPE_IGNORE], # storage supports ignore
@ -227,13 +227,13 @@ def setup_fw_update_parser(commands):
# There are no additional create options for firmware update
# define the delete command
delete_strategy_cmd = setup_delete_cmd(sub_cmds)
_ = setup_delete_cmd(sub_cmds)
# define the apply command
apply_strategy_cmd = setup_apply_cmd(sub_cmds)
_ = setup_apply_cmd(sub_cmds)
# define the abort command
abort_strategy_cmd = setup_abort_cmd(sub_cmds)
_ = setup_abort_cmd(sub_cmds)
# define the show command
show_strategy_cmd = setup_show_cmd(sub_cmds)
_ = setup_show_cmd(sub_cmds)
def setup_kube_rootca_update_parser(commands):
@ -283,13 +283,13 @@ def setup_kube_rootca_update_parser(commands):
help='Path to a file to be used, otherwise system will generate one')
# define the delete command
delete_strategy_cmd = setup_delete_cmd(sub_cmds)
_ = setup_delete_cmd(sub_cmds)
# define the apply command
apply_strategy_cmd = setup_apply_cmd(sub_cmds)
_ = setup_apply_cmd(sub_cmds)
# define the abort command
abort_strategy_cmd = setup_abort_cmd(sub_cmds)
_ = setup_abort_cmd(sub_cmds)
# define the show command
show_strategy_cmd = setup_show_cmd(sub_cmds)
_ = setup_show_cmd(sub_cmds)
def setup_kube_upgrade_parser(commands):
@ -332,13 +332,13 @@ def setup_kube_upgrade_parser(commands):
help='The kubernetes version')
# define the delete command
delete_strategy_cmd = setup_delete_cmd(sub_cmds)
_ = setup_delete_cmd(sub_cmds)
# define the apply command
apply_strategy_cmd = setup_apply_cmd(sub_cmds)
_ = setup_apply_cmd(sub_cmds)
# define the abort command
abort_strategy_cmd = setup_abort_cmd(sub_cmds)
_ = setup_abort_cmd(sub_cmds)
# define the show command
show_strategy_cmd = setup_show_cmd(sub_cmds)
_ = setup_show_cmd(sub_cmds)
def setup_patch_parser(commands):
@ -356,7 +356,7 @@ def setup_patch_parser(commands):
# define the create command
# alarm restrictions, defaults to strict
create_strategy_cmd = setup_create_cmd(
_ = setup_create_cmd(
sub_cmds,
[sw_update.APPLY_TYPE_SERIAL, # controller supports serial
sw_update.APPLY_TYPE_IGNORE],
@ -375,13 +375,13 @@ def setup_patch_parser(commands):
)
# define the delete command
delete_strategy_cmd = setup_delete_cmd(sub_cmds)
_ = setup_delete_cmd(sub_cmds)
# define the apply command
apply_strategy_cmd = setup_apply_cmd(sub_cmds)
_ = setup_apply_cmd(sub_cmds)
# define the abort command
abort_strategy_cmd = setup_abort_cmd(sub_cmds)
_ = setup_abort_cmd(sub_cmds)
# define the show command
show_strategy_cmd = setup_show_cmd(sub_cmds)
_ = setup_show_cmd(sub_cmds)
def setup_upgrade_parser(commands):
@ -428,13 +428,13 @@ def setup_upgrade_parser(commands):
help=argparse.SUPPRESS)
# define the delete command
delete_strategy_cmd = setup_delete_cmd(sub_cmds)
_ = setup_delete_cmd(sub_cmds)
# define the apply command
apply_strategy_cmd = setup_apply_cmd(sub_cmds)
_ = setup_apply_cmd(sub_cmds)
# define the abort command
abort_strategy_cmd = setup_abort_cmd(sub_cmds)
_ = setup_abort_cmd(sub_cmds)
# define the show command
show_strategy_cmd = setup_show_cmd(sub_cmds)
_ = setup_show_cmd(sub_cmds)
def process_main(argv=sys.argv[1:]): # pylint: disable=dangerous-default-value

View File

@ -462,7 +462,6 @@ class EventLogManagement(event_log_handlers_v1.EventLogHandler):
fm_probable_cause = fm_constants.ALARM_PROBABLE_CAUSE_65
fm_event_state = fm_constants.FM_ALARM_STATE_MSG
fm_severity = _fm_event_importance_mapping[log_data.importance]
fm_uuid = None
fm_reason_text = six.text_type(log_data.reason_text)
format_log = fm_api.Fault(fm_event_id, fm_event_state,
log_data.entity_type, log_data.entity,

View File

@ -1365,7 +1365,9 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
future.work(sysinv.get_kube_host_upgrades, self._platform_token)
future.result = (yield)
if not future.result.is_complete():
DLOG.error("Sysinv Get Kube Host Upgrades did not complete.")
error_string = "{} did not complete".format(activity)
DLOG.error(error_string)
response['reason'] = error_string
return
kube_host_upgrade_list = future.result.data["kube_host_upgrades"]

View File

@ -590,7 +590,7 @@ def delete_network_agents(token, host_name):
if (agent['host'] == host_name and
agent['agent_type'] in supported_agents):
api_cmd = url + "/v2.0/agents/%s" % agent['id']
response = rest_api_request(token, "DELETE", api_cmd,
rest_api_request(token, "DELETE", api_cmd,
api_cmd_headers)
num_agents_found = num_agents_found + 1

View File

@ -66,7 +66,6 @@ def build_get_dhcp_agent_networks_response(agent_id,
get_dhcp_agent_networks_response['result-data'] = list()
for x in range(0, random.randint(0, MAX_NETWORKS - 1)):
host_name = "compute-" + str(x)
net_idx = 0
net = "physnet0"
if use_strange_networks:

View File

@ -1988,7 +1988,6 @@ class TestFwUpdateStrategy(sw_update_testcase.SwUpdateStrategyTestCase):
default_instance_action=SW_UPDATE_INSTANCE_ACTION.STOP_START,
max_parallel_worker_hosts=10)
fw_update_controller_host_list = []
fw_update_worker_host_list = []
for host in list(self._host_table.values()):
if host._nfvi_host.admin_state == nfvi.objects.v1.HOST_ADMIN_STATE.UNLOCKED:

View File

@ -71,7 +71,6 @@ def build_get_agent_routers_response(agent_id):
get_agent_routers_response['result-data'] = list()
for x in range(0, random.randint(0, MAX_ROUTERS - 1)):
host_name = "compute-" + str(x)
get_agent_routers_response_entry = \
{"id": agent_id + "_router_" + str(x)}
get_agent_routers_response['result-data'].append(

View File

@ -90,7 +90,7 @@ class TestNFVPluginsK8SNodeTaint(testcase.NFVTestCase):
try:
kube_client = kubernetes_client.get_client()
response = kube_client.read_node(node_name)
except ApiException as e:
except ApiException:
return False
taints = response.spec.taints

View File

@ -2352,7 +2352,7 @@ class FwUpdateHostsStep(strategy.StrategyStep):
DLOG.error("failed to monitor firmware update ; no strategy")
else:
DLOG.error("get host request did not complete")
except Exception as e:
except Exception:
DLOG.exception("Caught exception interpreting host info")
DLOG.error("Response: %s" % response)

View File

@ -77,12 +77,9 @@ verbosity=2
# E127 continuation line over-indented for visual indent
# E128 continuation line under-indented for visual indent
# E129 visually indented line with same indent as next logical line
# flake8
# F841 local variable 'e' is assigned to but never used
ignore = H104,H404,H405,H501,
W503,W504,W605,
E121,E122,E124,E126,E127,E128,E129,
F841
E121,E122,E124,E126,E127,E128,E129
# H106 Dont put vim configuration in source files (off by default).
# H203 Use assertIs(Not)None to check for None (off by default).
# TODO: enable: H904 Delay string interpolations at logging calls (off by default).