Fix new pylint issues
new pylint 2.9.0 provides some new checkers and detects new errors with existing checkers: - consider-using-enumerate (disabled) - consider-using-from-import - arguments-renamed (disabled) - consider-using-with - consider-using-dict-items Change-Id: I4651f8bdaca13486a1dc6408f445d41779a95653
This commit is contained in:
parent
d10c9c2f9a
commit
4a9de5b27a
@ -56,7 +56,9 @@ disable=
|
||||
multiple-statements,
|
||||
duplicate-except,
|
||||
keyword-arg-before-vararg,
|
||||
useless-object-inheritance
|
||||
useless-object-inheritance,
|
||||
arguments-renamed,
|
||||
consider-using-enumerate
|
||||
|
||||
[BASIC]
|
||||
# Variable names can be 1 to 31 characters long, with lowercase and underscores
|
||||
|
@ -520,17 +520,16 @@ class UpdateHealthDb:
|
||||
session, db_pool_id, db_pool_dict, pools,
|
||||
lb_status, processed_pools, potential_offline_pools)
|
||||
|
||||
for pool_id in potential_offline_pools:
|
||||
for pool_id, pool in potential_offline_pools.items():
|
||||
# Skip if we eventually found a status for this pool
|
||||
if pool_id in processed_pools:
|
||||
continue
|
||||
try:
|
||||
# If the database doesn't already show the pool offline, update
|
||||
if potential_offline_pools[pool_id] != constants.OFFLINE:
|
||||
if pool != constants.OFFLINE:
|
||||
self._update_status(
|
||||
session, self.pool_repo, constants.POOL,
|
||||
pool_id, constants.OFFLINE,
|
||||
potential_offline_pools[pool_id])
|
||||
pool_id, constants.OFFLINE, pool)
|
||||
except sqlalchemy.orm.exc.NoResultFound:
|
||||
LOG.error("Pool %s is not in DB", pool_id)
|
||||
|
||||
|
@ -276,8 +276,8 @@ class ListenersController(base.BaseController):
|
||||
# new listener
|
||||
disallowed_protocols = [
|
||||
p
|
||||
for p in constants.L4_PROTOCOL_MAP
|
||||
if constants.L4_PROTOCOL_MAP[p] == l4_protocol
|
||||
for p, l4_p in constants.L4_PROTOCOL_MAP.items()
|
||||
if l4_p == l4_protocol
|
||||
]
|
||||
|
||||
for db_l in db_listeners:
|
||||
|
@ -37,7 +37,7 @@ from octavia.common import data_models
|
||||
from octavia.common import exceptions
|
||||
from octavia.common import stats
|
||||
from octavia.common import utils
|
||||
import octavia.common.validate as validate
|
||||
from octavia.common import validate
|
||||
from octavia.db import api as db_api
|
||||
from octavia.db import prepare as db_prepare
|
||||
from octavia.i18n import _
|
||||
|
@ -29,7 +29,7 @@ from octavia.api.v2.types import member as member_types
|
||||
from octavia.common import constants
|
||||
from octavia.common import data_models
|
||||
from octavia.common import exceptions
|
||||
import octavia.common.validate as validate
|
||||
from octavia.common import validate
|
||||
from octavia.db import api as db_api
|
||||
from octavia.db import prepare as db_prepare
|
||||
|
||||
|
@ -45,7 +45,8 @@ class LocalCertGenerator(cert_gen.CertGenerator):
|
||||
if not ca_cert:
|
||||
LOG.info("Using CA Certificate from config.")
|
||||
try:
|
||||
ca_cert = open(CONF.certificates.ca_certificate, 'rb').read()
|
||||
with open(CONF.certificates.ca_certificate, 'rb') as fp:
|
||||
fp.read()
|
||||
except IOError as e:
|
||||
raise exceptions.CertificateGenerationException(
|
||||
msg="Failed to load CA Certificate {0}."
|
||||
@ -54,7 +55,8 @@ class LocalCertGenerator(cert_gen.CertGenerator):
|
||||
if not ca_key:
|
||||
LOG.info("Using CA Private Key from config.")
|
||||
try:
|
||||
ca_key = open(CONF.certificates.ca_private_key, 'rb').read()
|
||||
with open(CONF.certificates.ca_private_key, 'rb') as fp:
|
||||
fp.read()
|
||||
except IOError as e:
|
||||
raise exceptions.CertificateGenerationException(
|
||||
msg="Failed to load CA Private Key {0}."
|
||||
|
@ -30,10 +30,9 @@ class BaseDataModel(object):
|
||||
"""Converts a data model to a dictionary."""
|
||||
calling_classes = calling_classes or []
|
||||
ret = {}
|
||||
for attr in self.__dict__:
|
||||
for attr, value in self.__dict__.items():
|
||||
if attr.startswith('_') or not kwargs.get(attr, True):
|
||||
continue
|
||||
value = self.__dict__[attr]
|
||||
if attr == 'tags':
|
||||
# tags is a list, it doesn't need recurse
|
||||
ret[attr] = value
|
||||
|
@ -26,7 +26,7 @@ from taskflow.types import failure
|
||||
|
||||
from octavia.common import constants
|
||||
from octavia.common import data_models
|
||||
import octavia.common.tls_utils.cert_parser as cert_parser
|
||||
from octavia.common.tls_utils import cert_parser
|
||||
from octavia.common import utils
|
||||
from octavia.controller.worker import task_utils as task_utilities
|
||||
from octavia.db import api as db_apis
|
||||
|
@ -27,7 +27,7 @@ from taskflow.types import failure
|
||||
from octavia.api.drivers import utils as provider_utils
|
||||
from octavia.common import constants
|
||||
from octavia.common import data_models
|
||||
import octavia.common.tls_utils.cert_parser as cert_parser
|
||||
from octavia.common.tls_utils import cert_parser
|
||||
from octavia.common import utils
|
||||
from octavia.controller.worker import task_utils as task_utilities
|
||||
from octavia.db import api as db_apis
|
||||
|
Loading…
Reference in New Issue
Block a user