From 33ab6587ac7d001b3d8493d4866ce3e97191aede Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Mon, 20 Sep 2021 18:08:03 +0200 Subject: [PATCH 33/59] misc: fix no-else-continue pylint error (#56982) --- src/authentic2/a2_rbac/management.py | 7 +++---- src/authentic2/idp/saml/saml2_endpoints.py | 17 ++++++++--------- src/authentic2/manager/views.py | 2 +- src/authentic2/utils/misc.py | 2 +- src/django_rbac/backends.py | 8 ++++---- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/authentic2/a2_rbac/management.py b/src/authentic2/a2_rbac/management.py index 3686307c..84761d8b 100644 --- a/src/authentic2/a2_rbac/management.py +++ b/src/authentic2/a2_rbac/management.py @@ -48,10 +48,9 @@ def update_ou_admin_roles(ou): if app_settings.MANAGED_CONTENT_TYPES == (): Role.objects.filter(slug=ou_slug, ou=ou).delete() continue - else: - ou_ct_admin_role = Role.objects.get_admin_role( - instance=ct, ou=ou, name=name, slug=ou_slug, update_slug=True, update_name=True - ) + ou_ct_admin_role = Role.objects.get_admin_role( + instance=ct, ou=ou, name=name, slug=ou_slug, update_slug=True, update_name=True + ) if not app_settings.MANAGED_CONTENT_TYPES or key in app_settings.MANAGED_CONTENT_TYPES: ou_ct_admin_role.add_child(ou_admin_role) else: diff --git a/src/authentic2/idp/saml/saml2_endpoints.py b/src/authentic2/idp/saml/saml2_endpoints.py index 23b25b87..651439b1 100644 --- a/src/authentic2/idp/saml/saml2_endpoints.py +++ b/src/authentic2/idp/saml/saml2_endpoints.py @@ -1312,15 +1312,14 @@ def slo_soap(request): if not p: logger.debug('slo cannot logout provider %s, it is no more known.', lib_session.provider_id) continue - else: - logger.debug('provider %s loaded', p) - policy = get_sp_options_policy(p) - if not policy: - logger.warning('No policy found for %s', lib_session.provider_id) - elif not policy.forward_slo: - logger.debug('%s configured not to receive slo', lib_session.provider_id) - if not policy or not policy.forward_slo: - lib_sessions.remove(lib_session) + logger.debug('provider %s loaded', p) + policy = get_sp_options_policy(p) + if not policy: + logger.warning('No policy found for %s', lib_session.provider_id) + elif not policy.forward_slo: + logger.debug('%s configured not to receive slo', lib_session.provider_id) + if not policy or not policy.forward_slo: + lib_sessions.remove(lib_session) set_session_dump_from_liberty_sessions(logout, found[0:1] + lib_sessions) try: logout.validateRequest() diff --git a/src/authentic2/manager/views.py b/src/authentic2/manager/views.py index 8a6c5c5b..f1912486 100644 --- a/src/authentic2/manager/views.py +++ b/src/authentic2/manager/views.py @@ -646,7 +646,7 @@ class HomepageView(TitleMixin, PermissionMixin, MediaMixin, TemplateView): permission = entry.get('permission') if permission == 'superuser' and not self.request.user.is_superuser: continue - elif permission and not self.request.user.has_perm_any(permission): + if permission and not self.request.user.has_perm_any(permission): continue entries.append(entry) # use possible key order to sort diff --git a/src/authentic2/utils/misc.py b/src/authentic2/utils/misc.py index b8d26649..d9906510 100644 --- a/src/authentic2/utils/misc.py +++ b/src/authentic2/utils/misc.py @@ -336,7 +336,7 @@ def make_url( for key, value in append.items(): if value is None: continue - elif isinstance(value, (tuple, list)): + if isinstance(value, (tuple, list)): url_params.extend({key: value}) else: url_params.appendlist(key, value) diff --git a/src/django_rbac/backends.py b/src/django_rbac/backends.py index b1262fea..e5a78bdf 100644 --- a/src/django_rbac/backends.py +++ b/src/django_rbac/backends.py @@ -154,9 +154,9 @@ class DjangoRBACBackend: for key, value in cache.items(): if isinstance(value, bool): continue - elif key == '__all__': + if key == '__all__': continue - elif key.startswith('ou.'): + if key.startswith('ou.'): if perm_or_perms & value: return True elif perm_or_perms & value: @@ -187,9 +187,9 @@ class DjangoRBACBackend: for key, value in cache.items(): if isinstance(value, bool): continue - elif key == '__all__': + if key == '__all__': continue - elif key.startswith('ou.'): + if key.startswith('ou.'): if has_ou_field and perm_or_perms & value: q.append(Q(ou_id=int(key[3:]))) continue -- 2.30.2