Fix new pep8/pylint errors

With new pylint release (2.4.1), new warnings were triggered:
- unnecessary-comprehension
- no-else-break
- no-else-continue
- import-outside-toplevel

Change-Id: I301cc9fc6b41e9e97f051df29d768b172cade636
This commit is contained in:
Gregory Thiemonge 2019-09-25 11:52:39 +02:00
parent 8c8f447d29
commit d5ffd2ca40
10 changed files with 16 additions and 19 deletions

View File

@ -167,7 +167,7 @@ class AmphoraInfo(object):
if (item[0] == 'IFLA_IFNAME' and
not item[1].startswith('eth')):
break
elif item[0] == 'IFLA_IFNAME':
if item[0] == 'IFLA_IFNAME':
interface_name = item[1]
if item[0] == 'IFLA_STATS64':
networks[interface_name] = dict(

View File

@ -97,7 +97,7 @@ class HAProxyQuery(object):
server_id=server_id))
list_results = results[2:].split('\n')
csv_reader = csv.DictReader(list_results)
return [row for row in csv_reader]
return list(csv_reader)
def get_pool_status(self):
"""Get status for each server and the pool as a whole.

View File

@ -333,11 +333,11 @@ def get_ipvsadm_info(ns_name, is_stats_cmd=False):
vs_fields.remove('Flags')
rs_fields = fields[index + 1:]
for key in list(value_mapping.keys()):
value_mapping[key]['Listener'] = [
i for i in zip(vs_fields, value_mapping[key]['Listener'])]
value_mapping[key]['Listener'] = list(
zip(vs_fields, value_mapping[key]['Listener']))
member_res = []
for member_value in value_mapping[key]['Members']:
member_res.append([i for i in zip(rs_fields, member_value)])
member_res.append(list(zip(rs_fields, member_value)))
value_mapping[key]['Members'] = member_res
return value_mapping

View File

@ -445,7 +445,7 @@ class ListenersController(base.BaseController):
list(listener.insert_headers.keys()), db_listener.protocol)
sni_containers = listener.sni_container_refs or []
tls_refs = [sni for sni in sni_containers]
tls_refs = list(sni_containers)
if listener.default_tls_container_ref:
tls_refs.append(listener.default_tls_container_ref)
self._validate_tls_refs(tls_refs)

View File

@ -142,8 +142,7 @@ class PoolsController(base.BaseController):
for attr in dir(request):
if attr.startswith('_') or attr in escaped_attrs:
continue
else:
request_attrs.append(attr)
request_attrs.append(attr)
for req_attr in request_attrs:
if (getattr(request, req_attr) and req_attr not in check_attrs):

View File

@ -46,8 +46,7 @@ class BarbicanCert(cert.Cert):
if self._cert_container.intermediates:
intermediates = encodeutils.to_utf8(
self._cert_container.intermediates.payload)
return [imd for imd in cert_parser.get_intermediates_pems(
intermediates)]
return list(cert_parser.get_intermediates_pems(intermediates))
return None
def get_private_key(self):

View File

@ -791,9 +791,9 @@ def handle_deprecation_compatibility():
def _enable_pydev(debugger_host, debugger_port):
try:
from pydev import pydevd
from pydev import pydevd # pylint: disable=import-outside-toplevel
except ImportError:
import pydevd
import pydevd # pylint: disable=import-outside-toplevel
pydevd.settrace(debugger_host,
port=int(debugger_port),
@ -802,7 +802,7 @@ def _enable_pydev(debugger_host, debugger_port):
def _enable_ptvsd(debuggger_host, debugger_port):
import ptvsd
import ptvsd # pylint: disable=import-outside-toplevel
# Allow other computers to attach to ptvsd at this IP address and port.
ptvsd.enable_attach(address=(debuggger_host, debugger_port),

View File

@ -490,7 +490,7 @@ class JinjaTemplater(object):
if not code:
continue
elif '-' in code:
if '-' in code:
low, hi = code.split('-')[:2]
retval.update(
str(i) for i in six.moves.xrange(int(low), int(hi) + 1))

View File

@ -475,7 +475,7 @@ class JinjaTemplater(object):
if not code:
continue
elif '-' in code:
if '-' in code:
low, hi = code.split('-')[:2]
retval.update(
str(i) for i in six.moves.xrange(int(low), int(hi) + 1))

View File

@ -149,10 +149,9 @@ def _split_x509s(xstr):
curr_pem_block = []
inside_x509 = False
continue
else:
if line == X509_BEG.decode('utf-8'):
curr_pem_block.append(line)
inside_x509 = True
if line == X509_BEG.decode('utf-8'):
curr_pem_block.append(line)
inside_x509 = True
def _parse_pkcs7_bundle(pkcs7):