From 3157bf63a6bcfb3d38c7c057de91a7539e0e56b0 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 22 Mar 2021 19:58:56 +0100 Subject: [PATCH] root: upgrade to pylint 2.7 Signed-off-by: Jens Langhammer --- .pylintrc | 2 +- authentik/admin/tests/test_api.py | 2 +- authentik/events/middleware.py | 2 +- authentik/policies/api.py | 1 + authentik/policies/engine.py | 6 +++--- authentik/providers/oauth2/views/authorize.py | 2 +- authentik/stages/user_write/stage.py | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.pylintrc b/.pylintrc index 130fdec22..c2675db1b 100644 --- a/.pylintrc +++ b/.pylintrc @@ -13,7 +13,7 @@ disable = similarities, cyclic-import, protected-access, - unsubscriptable-object # remove when pylint is upgraded to 2.6 + raise-missing-from load-plugins=pylint_django,pylint.extensions.bad_builtin django-settings-module=authentik.root.settings diff --git a/authentik/admin/tests/test_api.py b/authentik/admin/tests/test_api.py index 870c45c11..eaebf4fc9 100644 --- a/authentik/admin/tests/test_api.py +++ b/authentik/admin/tests/test_api.py @@ -27,7 +27,7 @@ class TestAdminAPI(TestCase): self.assertEqual(response.status_code, 200) body = loads(response.content) self.assertTrue( - any([task["task_name"] == "clean_expired_models" for task in body]) + any(task["task_name"] == "clean_expired_models" for task in body) ) def test_tasks_retry(self): diff --git a/authentik/events/middleware.py b/authentik/events/middleware.py index 4ab49842b..d9b865017 100644 --- a/authentik/events/middleware.py +++ b/authentik/events/middleware.py @@ -2,13 +2,13 @@ from functools import partial from typing import Callable -from django.contrib.auth.models import User from django.db.models import Model from django.db.models.signals import post_save, pre_delete from django.http import HttpRequest, HttpResponse from guardian.models import UserObjectPermission from authentik.core.middleware import LOCAL +from authentik.core.models import User from authentik.events.models import Event, EventAction, Notification from authentik.events.signals import EventNewThread from authentik.events.utils import model_to_dict diff --git a/authentik/policies/api.py b/authentik/policies/api.py index 6b96cffca..e550cdb77 100644 --- a/authentik/policies/api.py +++ b/authentik/policies/api.py @@ -31,6 +31,7 @@ class PolicyBindingModelForeignKey(PrimaryKeyRelatedField): def use_pk_only_optimization(self): return False + # pylint: disable=inconsistent-return-statements def to_internal_value(self, data): if self.pk_field is not None: data = self.pk_field.to_internal_value(data) diff --git a/authentik/policies/engine.py b/authentik/policies/engine.py index f2d4d9eb2..37dc27385 100644 --- a/authentik/policies/engine.py +++ b/authentik/policies/engine.py @@ -148,11 +148,11 @@ class PolicyEngine: return PolicyResult(self.empty_result) passing = False if self.mode == PolicyEngineMode.MODE_AND: - passing = all([x.passing for x in all_results]) + passing = all(x.passing for x in all_results) if self.mode == PolicyEngineMode.MODE_OR: - passing = any([x.passing for x in all_results]) + passing = any(x.passing for x in all_results) result = PolicyResult(passing) - result.messages = tuple([y for x in all_results for y in x.messages]) + result.messages = tuple(y for x in all_results for y in x.messages) return result @property diff --git a/authentik/providers/oauth2/views/authorize.py b/authentik/providers/oauth2/views/authorize.py index 9962a37bb..ee17feb80 100644 --- a/authentik/providers/oauth2/views/authorize.py +++ b/authentik/providers/oauth2/views/authorize.py @@ -454,7 +454,7 @@ class AuthorizationFlowInitView(PolicyAccessView): # OpenID clients can specify a `prompt` parameter, and if its set to consent we # need to inject a consent stage if PROMPT_CONSNET in self.params.prompt: - if not any([isinstance(x, ConsentStageView) for x in plan.stages]): + if not any(isinstance(x, ConsentStageView) for x in plan.stages): # Plan does not have any consent stage, so we add an in-memory one stage = ConsentStage( name="OAuth2 Provider In-memory consent stage", diff --git a/authentik/stages/user_write/stage.py b/authentik/stages/user_write/stage.py index a7269a168..33151d674 100644 --- a/authentik/stages/user_write/stage.py +++ b/authentik/stages/user_write/stage.py @@ -47,7 +47,7 @@ class UserWriteStageView(StageView): # Also check that we're not currently impersonating, so we don't update the session should_update_seesion = False if ( - any(["password" in x for x in data.keys()]) + any("password" in x for x in data.keys()) and self.request.user.pk == user.pk and SESSION_IMPERSONATE_USER not in self.request.session ):