From a4477a9beabc37e160d55e0ef2606c0e0da60cc5 Mon Sep 17 00:00:00 2001 From: Marc 'risson' Schmitt Date: Thu, 7 Dec 2023 09:39:49 +0100 Subject: [PATCH] lint Signed-off-by: Marc 'risson' Schmitt --- authentik/tenants/api.py | 2 -- authentik/tenants/checks.py | 5 ++++- authentik/tenants/management/__init__.py | 3 +++ authentik/tenants/models.py | 3 ++- authentik/tenants/tests/test_settings.py | 2 -- authentik/tenants/tests/utils.py | 8 ++++---- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/authentik/tenants/api.py b/authentik/tenants/api.py index c31949204..b1166e489 100644 --- a/authentik/tenants/api.py +++ b/authentik/tenants/api.py @@ -2,10 +2,8 @@ from hmac import compare_digest from django.http import HttpResponseNotFound -from django_tenants.utils import get_tenant from rest_framework import permissions from rest_framework.authentication import get_authorization_header -from rest_framework.fields import ReadOnlyField from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.generics import RetrieveUpdateAPIView from rest_framework.permissions import IsAdminUser diff --git a/authentik/tenants/checks.py b/authentik/tenants/checks.py index 319a39948..baaf902ef 100644 --- a/authentik/tenants/checks.py +++ b/authentik/tenants/checks.py @@ -1,3 +1,4 @@ +"""authentik tenants system checks""" from django.core.checks import Error, register from authentik.lib.config import CONFIG @@ -5,13 +6,15 @@ from authentik.lib.config import CONFIG @register() def check_embedded_outpost_disabled(app_configs, **kwargs): + """Check that when the tenants API is enabled, the embedded outpost is disabled""" if CONFIG.get_bool("tenants.enabled", False) and not CONFIG.get_bool( "outposts.disable_embedded_outpost" ): return [ Error( "Embedded outpost must be disabled when tenants API is enabled.", - hint="Disable embedded outpost by setting outposts.disable_embedded_outpost to False, or disable the tenants API by setting tenants.enabled to False", + hint="Disable embedded outpost by setting outposts.disable_embedded_outpost to " + "False, or disable the tenants API by setting tenants.enabled to False", ) ] return [] diff --git a/authentik/tenants/management/__init__.py b/authentik/tenants/management/__init__.py index 7c5cb468d..032509107 100644 --- a/authentik/tenants/management/__init__.py +++ b/authentik/tenants/management/__init__.py @@ -1,3 +1,4 @@ +"""authentik tenants management command utils""" from django.core.management.base import BaseCommand from django.db import connection from django_tenants.utils import get_public_schema_name @@ -23,6 +24,7 @@ class TenantCommand(BaseCommand): def handle(self, *args, **options): verbosity = int(options.get("verbosity")) + # pylint: disable=no-member schema_name = options["schema_name"] or self.schema_name connection.set_schema_to_public() if verbosity >= 1: @@ -35,6 +37,7 @@ class TenantCommand(BaseCommand): self.handle_per_tenant(*args, **options) def handle_per_tenant(self, *args, **options): + """The actual logic of the command.""" raise NotImplementedError( "subclasses of TenantCommand must provide a handle_per_tenant() method" ) diff --git a/authentik/tenants/models.py b/authentik/tenants/models.py index 843cda256..b1c3f3ac6 100644 --- a/authentik/tenants/models.py +++ b/authentik/tenants/models.py @@ -25,7 +25,8 @@ def _validate_schema_name(name): if not VALID_SCHEMA_NAME.match(name): raise ValidationError( _( - "Schema name must start with t_, only contain lowercase letters and numbers and be less than 63 characters." + "Schema name must start with t_, only contain lowercase letters and numbers and " + "be less than 63 characters." ) ) diff --git a/authentik/tenants/tests/test_settings.py b/authentik/tenants/tests/test_settings.py index d5d4e2b6e..9299f19b6 100644 --- a/authentik/tenants/tests/test_settings.py +++ b/authentik/tenants/tests/test_settings.py @@ -1,11 +1,9 @@ """Test Settings API""" -from json import loads from django.urls import reverse from django_tenants.utils import get_public_schema_name from authentik.core.tests.utils import create_test_admin_user -from authentik.lib.config import CONFIG from authentik.lib.generators import generate_id from authentik.tenants.models import Domain, Tenant from authentik.tenants.tests.utils import TenantAPITestCase diff --git a/authentik/tenants/tests/utils.py b/authentik/tenants/tests/utils.py index 11a095a07..3d926f512 100644 --- a/authentik/tenants/tests/utils.py +++ b/authentik/tenants/tests/utils.py @@ -4,7 +4,7 @@ from rest_framework.test import APITransactionTestCase class TenantAPITestCase(APITransactionTestCase): - # Overriden to force TRUNCATE CASCADE + # Overridden to force TRUNCATE CASCADE def _fixture_teardown(self): for db_name in self._databases_names(include_mirrors=False): call_command( @@ -32,7 +32,7 @@ class TenantAPITestCase(APITransactionTestCase): def assertSchemaExists(self, schema_name): with connection.cursor() as cursor: cursor.execute( - f"SELECT * FROM information_schema.schemata WHERE schema_name = %(schema_name)s", + "SELECT * FROM information_schema.schemata WHERE schema_name = %(schema_name)s", # nosec {"schema_name": schema_name}, ) self.assertEqual(cursor.rowcount, 1) @@ -42,7 +42,7 @@ class TenantAPITestCase(APITransactionTestCase): ) expected_tables = cursor.rowcount cursor.execute( - f"SELECT * FROM information_schema.tables WHERE table_schema = %(schema_name)s", + "SELECT * FROM information_schema.tables WHERE table_schema = %(schema_name)s", # nosec {"schema_name": schema_name}, ) self.assertEqual(cursor.rowcount, expected_tables) @@ -50,7 +50,7 @@ class TenantAPITestCase(APITransactionTestCase): def assertSchemaDoesntExist(self, schema_name): with connection.cursor() as cursor: cursor.execute( - f"SELECT * FROM information_schema.schemata WHERE schema_name = %(schema_name)s", + "SELECT * FROM information_schema.schemata WHERE schema_name = %(schema_name)s", # nosec {"schema_name": schema_name}, ) self.assertEqual(cursor.rowcount, 0)