*: fix type annotations for serializer model

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-08-16 13:23:22 +02:00
parent 54eeb7add6
commit 6000a33a8e
31 changed files with 38 additions and 38 deletions

View file

@ -20,7 +20,7 @@ from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
from guardian.mixins import GuardianUserMixin
from model_utils.managers import InheritanceManager
from rest_framework.serializers import BaseSerializer, Serializer
from rest_framework.serializers import Serializer
from structlog.stdlib import get_logger
from authentik.blueprints.models import ManagedModel
@ -482,7 +482,7 @@ class UserSourceConnection(SerializerModel, CreatedUpdatedModel):
objects = InheritanceManager()
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[Serializer]:
"""Get serializer for this model"""
raise NotImplementedError
@ -553,7 +553,7 @@ class Token(SerializerModel, ManagedModel, ExpiringModel):
description = models.TextField(default="", blank=True)
@property
def serializer(self) -> Serializer:
def serializer(self) -> type[Serializer]:
from authentik.core.api.tokens import TokenSerializer
return TokenSerializer

View file

@ -165,7 +165,7 @@ class Flow(SerializerModel, PolicyBindingModel):
stages = models.ManyToManyField(Stage, through="FlowStageBinding", blank=True)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.flows.api.flows import FlowSerializer
return FlowSerializer
@ -225,7 +225,7 @@ class FlowStageBinding(SerializerModel, PolicyBindingModel):
objects = InheritanceManager()
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.flows.api.bindings import FlowStageBindingSerializer
return FlowStageBindingSerializer

View file

@ -12,7 +12,7 @@ class SerializerModel(models.Model):
"""Base Abstract Model which has a serializer"""
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
"""Get serializer for this model"""
raise NotImplementedError

View file

@ -24,7 +24,7 @@ class DummyPolicy(Policy):
wait_max = models.IntegerField(default=30)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.policies.dummy.api import DummyPolicySerializer
return DummyPolicySerializer

View file

@ -54,7 +54,7 @@ class EventMatcherPolicy(Policy):
)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.policies.event_matcher.api import EventMatcherPolicySerializer
return EventMatcherPolicySerializer

View file

@ -21,7 +21,7 @@ class PasswordExpiryPolicy(Policy):
days = models.IntegerField()
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.policies.expiry.api import PasswordExpiryPolicySerializer
return PasswordExpiryPolicySerializer

View file

@ -14,7 +14,7 @@ class ExpressionPolicy(Policy):
expression = models.TextField()
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.policies.expression.api import ExpressionPolicySerializer
return ExpressionPolicySerializer

View file

@ -26,7 +26,7 @@ class HaveIBeenPwendPolicy(Policy):
allowed_count = models.IntegerField(default=0)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.policies.hibp.api import HaveIBeenPwendPolicySerializer
return HaveIBeenPwendPolicySerializer

View file

@ -102,7 +102,7 @@ class PolicyBinding(SerializerModel):
return PolicyResult(False)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.policies.api.bindings import PolicyBindingSerializer
return PolicyBindingSerializer

View file

@ -33,7 +33,7 @@ class PasswordPolicy(Policy):
error_message = models.TextField()
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.policies.password.api import PasswordPolicySerializer
return PasswordPolicySerializer

View file

@ -25,7 +25,7 @@ class ReputationPolicy(Policy):
threshold = models.IntegerField(default=-5)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.policies.reputation.api import ReputationPolicySerializer
return ReputationPolicySerializer
@ -73,7 +73,7 @@ class Reputation(SerializerModel):
updated = models.DateTimeField(auto_now_add=True)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.policies.reputation.api import ReputationSerializer
return ReputationSerializer

View file

@ -58,7 +58,7 @@ class PlexSource(Source):
return "ak-source-plex-form"
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.sources.plex.api.source import PlexSourceSerializer
return PlexSourceSerializer

View file

@ -23,7 +23,7 @@ class AuthenticatorDuoStage(ConfigurableStage, Stage):
api_hostname = models.TextField()
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.authenticator_duo.api import AuthenticatorDuoStageSerializer
return AuthenticatorDuoStageSerializer

View file

@ -127,7 +127,7 @@ class AuthenticatorSMSStage(ConfigurableStage, Stage):
raise
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.authenticator_sms.api import AuthenticatorSMSStageSerializer
return AuthenticatorSMSStageSerializer
@ -186,7 +186,7 @@ class SMSDevice(SerializerModel, SideChannelDevice):
return self.phone_number.startswith("hash:")
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.authenticator_sms.api import SMSDeviceSerializer
return SMSDeviceSerializer

View file

@ -16,7 +16,7 @@ class AuthenticatorStaticStage(ConfigurableStage, Stage):
token_count = models.IntegerField(default=6)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.authenticator_static.api import AuthenticatorStaticStageSerializer
return AuthenticatorStaticStageSerializer

View file

@ -23,7 +23,7 @@ class AuthenticatorTOTPStage(ConfigurableStage, Stage):
digits = models.IntegerField(choices=TOTPDigits.choices)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.authenticator_totp.api import AuthenticatorTOTPStageSerializer
return AuthenticatorTOTPStageSerializer

View file

@ -70,7 +70,7 @@ class AuthenticatorValidateStage(Stage):
)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.authenticator_validate.api import AuthenticatorValidateStageSerializer
return AuthenticatorValidateStageSerializer

View file

@ -82,7 +82,7 @@ class AuthenticateWebAuthnStage(ConfigurableStage, Stage):
)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.authenticator_webauthn.api import AuthenticateWebAuthnStageSerializer
return AuthenticateWebAuthnStageSerializer

View file

@ -19,7 +19,7 @@ class CaptchaStage(Stage):
)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.captcha.api import CaptchaStageSerializer
return CaptchaStageSerializer

View file

@ -31,7 +31,7 @@ class ConsentStage(Stage):
)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.consent.api import ConsentStageSerializer
return ConsentStageSerializer

View file

@ -11,7 +11,7 @@ class DenyStage(Stage):
"""Cancells the current flow."""
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.deny.api import DenyStageSerializer
return DenyStageSerializer

View file

@ -13,7 +13,7 @@ class DummyStage(Stage):
__debug_only__ = True
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.dummy.api import DummyStageSerializer
return DummyStageSerializer

View file

@ -82,7 +82,7 @@ class EmailStage(Stage):
template = models.TextField(default=EmailTemplates.PASSWORD_RESET)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.email.api import EmailStageSerializer
return EmailStageSerializer

View file

@ -92,7 +92,7 @@ class IdentificationStage(Stage):
show_source_labels = models.BooleanField(default=False)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.identification.api import IdentificationStageSerializer
return IdentificationStageSerializer

View file

@ -27,7 +27,7 @@ class InvitationStage(Stage):
)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.invitation.api import InvitationStageSerializer
return InvitationStageSerializer

View file

@ -48,7 +48,7 @@ class PasswordStage(ConfigurableStage, Stage):
)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.password.api import PasswordStageSerializer
return PasswordStageSerializer

View file

@ -1,5 +1,5 @@
"""prompt models"""
from typing import Any, Optional
from typing import Any, Optional, Type
from urllib.parse import urlparse, urlunparse
from uuid import uuid4
@ -111,7 +111,7 @@ class Prompt(SerializerModel):
placeholder_expression = models.BooleanField(default=False)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> Type[BaseSerializer]:
from authentik.stages.prompt.api import PromptSerializer
return PromptSerializer
@ -207,7 +207,7 @@ class PromptStage(Stage):
validation_policies = models.ManyToManyField(Policy, blank=True)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.prompt.api import PromptStageSerializer
return PromptStageSerializer

View file

@ -12,7 +12,7 @@ class UserDeleteStage(Stage):
Use with caution."""
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.user_delete.api import UserDeleteStageSerializer
return UserDeleteStageSerializer

View file

@ -23,7 +23,7 @@ class UserLoginStage(Stage):
)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.user_login.api import UserLoginStageSerializer
return UserLoginStageSerializer

View file

@ -11,7 +11,7 @@ class UserLogoutStage(Stage):
"""Resets the users current session."""
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.user_logout.api import UserLogoutStageSerializer
return UserLogoutStageSerializer

View file

@ -32,7 +32,7 @@ class UserWriteStage(Stage):
)
@property
def serializer(self) -> BaseSerializer:
def serializer(self) -> type[BaseSerializer]:
from authentik.stages.user_write.api import UserWriteStageSerializer
return UserWriteStageSerializer