*: fix type annotations for serializer model
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
54eeb7add6
commit
6000a33a8e
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in New Issue