Merge "pylint: fix several warnings"

This commit is contained in:
Zuul 2019-01-15 11:22:36 +00:00 committed by Gerrit Code Review
commit 6299fdbdc0
12 changed files with 30 additions and 34 deletions

View File

@ -27,30 +27,21 @@ disable=
attribute-defined-outside-init,
bad-indentation,
broad-except,
cell-var-from-loop,
dangerous-default-value,
deprecated-method, # TODO
exec-used,
fixme,
keyword-arg-before-vararg, # TODO
logging-not-lazy,
pointless-string-statement,
protected-access,
raising-format-tuple,
redefined-builtin,
redefined-outer-name,
reimported,
signature-differs,
super-init-not-called,
undefined-loop-variable,
unidiomatic-typecheck,
unnecessary-pass,
unused-argument,
unused-import,
unused-wildcard-import,
useless-else-on-loop,
useless-super-delegation,
using-constant-test,
wildcard-import,
# "C" Coding convention violations
abstract-method,

View File

@ -345,6 +345,7 @@ def handle(request, message=None, redirect=None, ignore=False,
ret = handle_recoverable(request, user_message, redirect, ignore,
escalate, handled, force_silence, force_log,
log_method, log_entry, log_level)
# pylint: disable=using-constant-test
if ret:
return ret

View File

@ -351,7 +351,7 @@ class Column(html.HTMLElement):
if summation is not None and summation not in self.summation_methods:
raise ValueError(
"Summation method %(summation)s must be one of %(keys)s.",
"Summation method %(summation)s must be one of %(keys)s." %
{'summation': summation,
'keys': ", ".join(self.summation_methods.keys())})
self.summation = summation

View File

@ -86,6 +86,19 @@ class KeystoneBackend(object):
else:
return None
def _get_auth_backend(self, auth_url, **kwargs):
for plugin in self.auth_plugins:
unscoped_auth = plugin.get_plugin(auth_url=auth_url, **kwargs)
if unscoped_auth:
return plugin, unscoped_auth
else:
msg = _('No authentication backend could be determined to '
'handle the provided credentials.')
LOG.warning('No authentication backend could be determined to '
'handle the provided credentials. This is likely a '
'configuration error that should be addressed.')
raise exceptions.KeystoneAuthException(msg)
def authenticate(self, auth_url=None, **kwargs):
"""Authenticates a user via the Keystone Identity API."""
LOG.debug('Beginning user authentication')
@ -100,18 +113,7 @@ class KeystoneBackend(object):
"version to use by Horizon. Using v3 endpoint for "
"authentication.")
for plugin in self.auth_plugins:
unscoped_auth = plugin.get_plugin(auth_url=auth_url, **kwargs)
if unscoped_auth:
break
else:
msg = _('No authentication backend could be determined to '
'handle the provided credentials.')
LOG.warning('No authentication backend could be determined to '
'handle the provided credentials. This is likely a '
'configuration error that should be addressed.')
raise exceptions.KeystoneAuthException(msg)
plugin, unscoped_auth = self._get_auth_backend(auth_url, **kwargs)
# the recent project id a user might have set in a cookie
recent_project = None

View File

@ -36,6 +36,7 @@ from openstack_auth import plugin
# This is historic and is added back in to not break older versions of
# Horizon, fix to Horizon to remove this requirement was committed in
# Juno
# pylint: disable=unused-import
from openstack_auth.forms import Login # noqa:F401
from openstack_auth import user as auth_user
from openstack_auth import utils

View File

@ -225,8 +225,9 @@ def cinderclient(request, version=None):
service_names = ('volumev3', 'volume')
else:
service_names = ('volume',)
for name, cinder_url in cinder_urls:
for name, _url in cinder_urls:
if name in service_names:
cinder_url = _url
break
else:
raise exceptions.ServiceCatalogException(

View File

@ -201,18 +201,18 @@ def swift_get_container(request, container_name, with_data=True):
@profiler.trace
@safe_swift_exception
def swift_create_container(request, name, metadata=({})):
def swift_create_container(request, name, metadata=None):
if swift_container_exists(request, name):
raise exceptions.AlreadyExists(name, 'container')
headers = _metadata_to_header(metadata)
headers = _metadata_to_header(metadata or {})
swift_api(request).put_container(name, headers=headers)
return Container({'name': name})
@profiler.trace
@safe_swift_exception
def swift_update_container(request, name, metadata=({})):
headers = _metadata_to_header(metadata)
def swift_update_container(request, name, metadata=None):
headers = _metadata_to_header(metadata or {})
swift_api(request).post_container(name, headers=headers)
return Container({'name': name})

View File

@ -39,8 +39,6 @@ from openstack_dashboard.dashboards.admin.networks.subnets \
from openstack_dashboard.dashboards.admin.networks \
import tables as networks_tables
from openstack_dashboard.dashboards.admin.networks import workflows
from openstack_dashboard.dashboards.project.networks import views \
as project_view
class IndexView(tables.DataTableView):
@ -130,7 +128,7 @@ class IndexView(tables.DataTableView):
return filters
class CreateView(project_view.CreateView):
class CreateView(user_views.CreateView):
workflow_class = workflows.CreateNetwork

View File

@ -472,8 +472,9 @@ class UpdateDomain(workflows.Workflow):
for role in available_roles:
groups_added = 0
field_name = member_step.get_member_field_name(role.id)
domain_group_ids = [x.id for x in domain_groups]
for group_id in data[field_name]:
if not filter(lambda x: group_id == x.id, domain_groups):
if group_id not in domain_group_ids:
api.keystone.add_group_role(request,
role=role.id,
group=group_id,

View File

@ -902,9 +902,9 @@ class UpdateProject(workflows.Workflow):
for role in available_roles:
groups_added = 0
field_name = member_step.get_member_field_name(role.id)
project_group_ids = [x.id for x in project_groups]
for group_id in data[field_name]:
if not list(filter(lambda x: group_id == x.id,
project_groups)):
if group_id not in project_group_ids:
api.keystone.add_group_role(request,
role=role.id,
group=group_id,

View File

@ -407,6 +407,7 @@ if os.path.exists(LOCAL_SETTINGS_DIR_PATH):
if filename.endswith(".py"):
try:
with open(os.path.join(dirpath, filename)) as f:
# pylint: disable=exec-used
exec(f.read())
except Exception as e:
_LOG.exception(

View File

@ -62,6 +62,6 @@ def get_available_themes(available_themes, default_theme, selectable_themes):
default_theme = selectable_themes[0][0]
logging.warning("Your DEFAULT_THEME is not configured in your "
"selectable themes, therefore using %s as your "
"default theme." % default_theme)
"default theme.", default_theme)
return new_theme_list, selectable_themes, default_theme