Merge "Pylint: Enable Check for Dangerous Default Value"

This commit is contained in:
Zuul 2019-08-20 21:05:30 +00:00 committed by Gerrit Code Review
commit c0949589b5
17 changed files with 63 additions and 28 deletions

View File

@ -34,7 +34,6 @@ load-plugins=
# The following warnings should be fixed:
# fixme (todo, xxx, fixme)
# W0101: unreachable
# W0102: dangerous-default-value
# W0105: pointless-string-statement
# W0106: expression-not-assigned
# W0107: unnecessary-pass
@ -80,7 +79,7 @@ load-plugins=
# E1124: redundant-keyword-arg
# E1136: unsubscriptable-object
# E1205: logging-too-many-args
disable=C, R, fixme, W0101, W0102, W0105, W0106, W0107, W0108, W0110, W0123, W0150,
disable=C, R, fixme, W0101, W0105, W0106, W0107, W0108, W0110, W0123, W0150,
W0201, W0211, W0212, W0221, W0223, W0231, W0235, W0311, W0402, W0403, W0404,
W0603, W0612, W0613, W0621, W0622, W0631, W0632, W0701, W0703,
W1113, W1201, W1401, W1505,

View File

@ -336,9 +336,11 @@ class ClusterController(rest.RestController):
@wsme_pecan.wsexpose(ClusterCollection, [Query], types.uuid, types.uuid,
int, wtypes.text, wtypes.text)
def get_all(self, q=[], parent_uuid=None,
def get_all(self, q=None, parent_uuid=None,
marker=None, limit=None, sort_key='id', sort_dir='asc'):
"""Retrieve a list of Clusters."""
if q is None:
q = []
return self._get_cluster_collection(parent_uuid, marker, limit,
sort_key, sort_dir, q=q)

View File

@ -455,7 +455,9 @@ class KubeAppHelper(object):
"state of the patch(es)."))
return response
def _patch_report_app_dependencies(self, name, patches=[]):
def _patch_report_app_dependencies(self, name, patches=None):
if patches is None:
patches = []
try:
system = self._dbapi.isystem_get_one()
patch_api.patch_report_app_dependencies(

View File

@ -198,9 +198,11 @@ class ServiceParameterController(rest.RestController):
@wsme_pecan.wsexpose(ServiceParameterCollection, [Query],
types.uuid, wtypes.text,
wtypes.text, wtypes.text, wtypes.text)
def get_all(self, q=[], marker=None, limit=None,
def get_all(self, q=None, marker=None, limit=None,
sort_key='id', sort_dir='asc'):
"""Retrieve a list of service parameters."""
if q is None:
q = []
sort_key = ['section', 'name']
return self._get_service_parameter_collection(marker, limit,
sort_key,

View File

@ -33,9 +33,11 @@ class AuthTokenMiddleware(auth_token.AuthProtocol):
for public routes in the API.
"""
def __init__(self, app, conf, public_api_routes=[]):
def __init__(self, app, conf, public_api_routes=None):
self._sysinv_app = app
route_pattern_tpl = '%s(\.json|\.xml)?$'
if public_api_routes is None:
public_api_routes = []
try:
self.public_api_routes = [re.compile(route_pattern_tpl % route_tpl)

View File

@ -57,7 +57,7 @@ class ActivatedExtensionManager(enabled.EnabledExtensionManager):
"""
def __init__(self, namespace, enabled_names, invoke_on_load=True,
invoke_args=(), invoke_kwds={}):
invoke_args=(), invoke_kwds=None):
def local_check_func(ext):
return should_use_extension(namespace, ext, enabled_names)
@ -67,5 +67,5 @@ class ActivatedExtensionManager(enabled.EnabledExtensionManager):
check_func=local_check_func,
invoke_on_load=invoke_on_load,
invoke_args=invoke_args,
invoke_kwds=invoke_kwds,
invoke_kwds=invoke_kwds if invoke_kwds is not None else {},
)

View File

@ -121,11 +121,13 @@ class Health(object):
return success, allowed, affecting
def get_alarms_degrade(self, context, alarm_ignore_list=[],
def get_alarms_degrade(self, context, alarm_ignore_list=None,
entity_instance_id_filter=""):
"""Return all the alarms that cause the degrade"""
db_alarms = fmclient(context).alarm.list(include_suppress=True)
degrade_alarms = []
if alarm_ignore_list is None:
alarm_ignore_list = []
for db_alarm in db_alarms:
if isinstance(db_alarm, tuple):

View File

@ -55,7 +55,9 @@ class PeriodicService(rpc_service.Service, periodic_task.PeriodicTasks):
context=admin_context)
def prepare_service(argv=[]):
def prepare_service(argv=None):
if argv is None:
argv = []
rpc.set_defaults(control_exchange='sysinv')
cfg.set_defaults(log.log_opts,
default_log_levels=['amqplib=WARN',

View File

@ -2462,11 +2462,14 @@ class DockerHelper(object):
return None
def make_armada_request(self, request, manifest_file='', overrides_str='',
app_releases=[], logfile=None):
app_releases=None, logfile=None):
if logfile is None:
logfile = request + '.log'
if app_releases is None:
app_releases = []
rc = True
# Instruct Armada to use the tiller service since it does not properly

View File

@ -741,7 +741,9 @@ class ConductorManager(service.PeriodicService):
return line
def _dnsmasq_addn_host_entry_to_string(self, ip_addr, hostname,
aliases=[]):
aliases=None):
if aliases is None:
aliases = []
line = "%s %s" % (ip_addr, hostname)
for alias in aliases:
line = "%s %s" % (line, alias)
@ -10109,7 +10111,7 @@ class ConductorManager(service.PeriodicService):
"""
return self._helm.get_helm_application_overrides(app_name, cnamespace)
def merge_overrides(self, context, file_overrides=[], set_overrides=[]):
def merge_overrides(self, context, file_overrides=None, set_overrides=None):
"""Merge the file and set overrides into a single chart overrides.
:param context: request context.

View File

@ -1692,7 +1692,7 @@ class ConductorAPI(sysinv.openstack.common.rpc.proxy.RpcProxy):
app_name=app_name,
cnamespace=cnamespace))
def merge_overrides(self, context, file_overrides=[], set_overrides=[]):
def merge_overrides(self, context, file_overrides=None, set_overrides=None):
"""Merge the file and set overrides into a single chart overrides.
:param context: request context.
@ -1701,6 +1701,10 @@ class ConductorAPI(sysinv.openstack.common.rpc.proxy.RpcProxy):
:returns: merged overrides string
"""
if file_overrides is None:
file_overrides = []
if set_overrides is None:
set_overrides = []
return self.call(context,
self.make_msg('merge_overrides',
file_overrides=file_overrides,

View File

@ -377,7 +377,7 @@ class HelmOperator(object):
LOG.debug("Chart %s can be found in repo: %s" % (chart_name, repo))
return metadata_name, repo, chart_tarfile
def merge_overrides(self, file_overrides=[], set_overrides=[]):
def merge_overrides(self, file_overrides=None, set_overrides=None):
""" Merge helm overrides together.
:param values: A dict of different types of user override values,
@ -385,6 +385,10 @@ class HelmOperator(object):
'set' (which generally specify one override).
"""
if file_overrides is None:
file_overrides = []
if set_overrides is None:
set_overrides = []
# At this point we have potentially two separate types of overrides
# specified by system or user, values from files and values passed in
# via --set . We need to ensure that we call helm using the same

View File

@ -409,7 +409,7 @@ class OpenstackBaseHelm(base.BaseHelm):
return newprivatekey, newpublickey
def _oslo_multistring_override(self, name=None, values=[]):
def _oslo_multistring_override(self, name=None, values=None):
"""
Generate helm multistring dictionary override for specified option
name with multiple values.

View File

@ -28,8 +28,11 @@ class DBError(Exception):
class DBDuplicateEntry(DBError):
"""Wraps an implementation specific exception."""
def __init__(self, columns=[], inner_exception=None):
self.columns = columns
def __init__(self, columns=None, inner_exception=None):
if columns is None:
self.columns = []
else:
self.columns = columns
super(DBDuplicateEntry, self).__init__(inner_exception)

View File

@ -29,7 +29,7 @@ class CommandFilter(object):
self.args = args
self.real_exec = None
def get_exec(self, exec_dirs=[]):
def get_exec(self, exec_dirs=None):
"""Returns existing executable, or empty string if none found."""
if self.real_exec is not None:
return self.real_exec
@ -37,7 +37,7 @@ class CommandFilter(object):
if self.exec_path.startswith('/'):
if os.access(self.exec_path, os.X_OK):
self.real_exec = self.exec_path
else:
elif exec_dirs is not None:
for binary_path in exec_dirs:
expanded_path = os.path.join(binary_path, self.exec_path)
if os.access(expanded_path, os.X_OK):
@ -49,7 +49,7 @@ class CommandFilter(object):
"""Only check that the first argument (command) matches exec_path."""
return os.path.basename(self.exec_path) == userargs[0]
def get_command(self, userargs, exec_dirs=[]):
def get_command(self, userargs, exec_dirs=None):
"""Returns command to execute (with sudo -u if run_as != root)."""
to_exec = self.get_exec(exec_dirs=exec_dirs) or self.exec_path
if (self.run_as != 'root'):
@ -122,7 +122,9 @@ class PathFilter(CommandFilter):
args_equal_or_pass and
paths_are_within_base_dirs)
def get_command(self, userargs, exec_dirs=[]):
def get_command(self, userargs, exec_dirs=None):
if exec_dirs is None:
exec_dirs = []
command, arguments = userargs[0], userargs[1:]
# convert path values to canonical ones; copy other args as is
@ -146,7 +148,9 @@ class DnsmasqFilter(CommandFilter):
return True
return False
def get_command(self, userargs, exec_dirs=[]):
def get_command(self, userargs, exec_dirs=None):
if exec_dirs is None:
exec_dirs = []
to_exec = self.get_exec(exec_dirs=exec_dirs) or self.exec_path
dnsmasq_pos = userargs.index('dnsmasq')
return [to_exec] + userargs[dnsmasq_pos + 1:]

View File

@ -121,7 +121,7 @@ def load_filters(filters_path):
return filterlist
def match_filter(filter_list, userargs, exec_dirs=[]):
def match_filter(filter_list, userargs, exec_dirs=None):
"""
Checks user command and arguments through command filters and
returns the first matching filter.
@ -130,6 +130,8 @@ def match_filter(filter_list, userargs, exec_dirs=[]):
best filter match.
"""
first_not_executable_filter = None
if exec_dirs is None:
exec_dirs = []
for f in filter_list:
if f.match(userargs):

View File

@ -68,9 +68,10 @@ def get_reqs_from_files(requirements_files):
return []
def parse_requirements(requirements_files=['requirements.txt',
'tools/pip-requires']):
def parse_requirements(requirements_files=None):
requirements = []
if requirements_files is None:
requirements_files = ['requirements.txt', 'tools/pip-requires']
for line in get_reqs_from_files(requirements_files):
# For the requirements list, we need to inject only the portion
# after egg= so that distutils knows the package it's looking for
@ -97,8 +98,9 @@ def parse_requirements(requirements_files=['requirements.txt',
return requirements
def parse_dependency_links(requirements_files=['requirements.txt',
'tools/pip-requires']):
def parse_dependency_links(requirements_files=None):
if requirements_files is None:
requirements_files = ['requirements.txt', 'tools/pip-requires']
dependency_links = []
# dependency_links inject alternate locations to find packages listed
# in requirements