diff --git a/.pylintrc b/.pylintrc index e69af02d0f..41f986b43f 100644 --- a/.pylintrc +++ b/.pylintrc @@ -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, diff --git a/horizon/exceptions.py b/horizon/exceptions.py index 2b8820ddc1..01fa4f9f01 100644 --- a/horizon/exceptions.py +++ b/horizon/exceptions.py @@ -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 diff --git a/horizon/tables/base.py b/horizon/tables/base.py index 8144c508ec..daf64019e4 100644 --- a/horizon/tables/base.py +++ b/horizon/tables/base.py @@ -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 diff --git a/openstack_auth/backend.py b/openstack_auth/backend.py index 5be15e8106..8116cabcec 100644 --- a/openstack_auth/backend.py +++ b/openstack_auth/backend.py @@ -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 diff --git a/openstack_auth/views.py b/openstack_auth/views.py index c6d10ef21d..04e13043ce 100644 --- a/openstack_auth/views.py +++ b/openstack_auth/views.py @@ -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 diff --git a/openstack_dashboard/api/cinder.py b/openstack_dashboard/api/cinder.py index 215fcd13e7..93f341888f 100644 --- a/openstack_dashboard/api/cinder.py +++ b/openstack_dashboard/api/cinder.py @@ -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( diff --git a/openstack_dashboard/api/swift.py b/openstack_dashboard/api/swift.py index 06baadba1d..bbca5065a7 100644 --- a/openstack_dashboard/api/swift.py +++ b/openstack_dashboard/api/swift.py @@ -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}) diff --git a/openstack_dashboard/dashboards/admin/networks/views.py b/openstack_dashboard/dashboards/admin/networks/views.py index 6cc52d08d6..61b9223a46 100644 --- a/openstack_dashboard/dashboards/admin/networks/views.py +++ b/openstack_dashboard/dashboards/admin/networks/views.py @@ -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 diff --git a/openstack_dashboard/dashboards/identity/domains/workflows.py b/openstack_dashboard/dashboards/identity/domains/workflows.py index 742c49e489..81bf94b85b 100644 --- a/openstack_dashboard/dashboards/identity/domains/workflows.py +++ b/openstack_dashboard/dashboards/identity/domains/workflows.py @@ -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, diff --git a/openstack_dashboard/dashboards/identity/projects/workflows.py b/openstack_dashboard/dashboards/identity/projects/workflows.py index 4323481a91..0b6e648c5f 100644 --- a/openstack_dashboard/dashboards/identity/projects/workflows.py +++ b/openstack_dashboard/dashboards/identity/projects/workflows.py @@ -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, diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py index ed93897128..74a7fd51e7 100644 --- a/openstack_dashboard/settings.py +++ b/openstack_dashboard/settings.py @@ -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( diff --git a/openstack_dashboard/theme_settings.py b/openstack_dashboard/theme_settings.py index 9f142641c7..b4ac695207 100644 --- a/openstack_dashboard/theme_settings.py +++ b/openstack_dashboard/theme_settings.py @@ -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