Enable undefined-loop-variable pylint check
This required a trivial refactor of two existing cases in the codebase. These two cases were perfectly correct, but the check uncovered a 3rd case which was a real bug (fixed separately). The new versions also make it clear that if the loop fails to break early then the 'result' is None (and thus an error) and not simply the last element. On balance, it's probably worth enforcing this small inconvenience to coding style. Change-Id: I780a95241f1454c6886d91f980eb9ada7678a119 Related-Bug: #1362466
This commit is contained in:
parent
d2ae88617f
commit
35b6d164d6
|
@ -56,7 +56,6 @@ disable=
|
|||
signature-differs,
|
||||
star-args,
|
||||
super-init-not-called,
|
||||
undefined-loop-variable,
|
||||
unnecessary-lambda,
|
||||
unnecessary-pass,
|
||||
unpacking-non-sequence,
|
||||
|
|
|
@ -158,12 +158,13 @@ def _get_first_ip_from_port(port):
|
|||
|
||||
def _get_server_health_option(config):
|
||||
"""return the first active health option."""
|
||||
for monitor in config['healthmonitors']:
|
||||
for m in config['healthmonitors']:
|
||||
# not checking the status of healthmonitor for two reasons:
|
||||
# 1) status field is absent in HealthMonitor model
|
||||
# 2) only active HealthMonitors are fetched with
|
||||
# LoadBalancerCallbacks.get_logical_device
|
||||
if monitor['admin_state_up']:
|
||||
if m['admin_state_up']:
|
||||
monitor = m
|
||||
break
|
||||
else:
|
||||
return '', []
|
||||
|
|
Loading…
Reference in New Issue