*: use py3.10 syntax for unions, remove old Type[] import when possible

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-12-30 14:59:01 +01:00
parent 1e1876b34c
commit c249b55ff5
49 changed files with 92 additions and 110 deletions

View File

@ -1,7 +1,7 @@
"""API Authentication"""
from base64 import b64decode
from binascii import Error
from typing import Any, Optional, Union
from typing import Any, Optional
from django.conf import settings
from rest_framework.authentication import BaseAuthentication, get_authorization_header
@ -69,7 +69,7 @@ def token_secret_key(value: str) -> Optional[User]:
class TokenAuthentication(BaseAuthentication):
"""Token-based authentication using HTTP Bearer authentication"""
def authenticate(self, request: Request) -> Union[tuple[User, Any], None]:
def authenticate(self, request: Request) -> tuple[User, Any] | None:
"""Token-based authentication using HTTP Bearer authentication"""
auth = get_authorization_header(request)

View File

@ -15,7 +15,6 @@ import authentik.lib.models
def migrate_sessions(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
db_alias = schema_editor.connection.alias
from django.contrib.sessions.backends.cache import KEY_PREFIX
from django.core.cache import cache

View File

@ -12,7 +12,6 @@ import authentik.core.models
def migrate_sessions(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
db_alias = schema_editor.connection.alias
from django.contrib.sessions.backends.cache import KEY_PREFIX
from django.core.cache import cache

View File

@ -1,7 +1,7 @@
"""authentik core models"""
from datetime import timedelta
from hashlib import md5, sha256
from typing import Any, Optional, Type
from typing import Any, Optional
from urllib.parse import urlencode
from uuid import uuid4
@ -224,7 +224,7 @@ class Provider(SerializerModel):
raise NotImplementedError
@property
def serializer(self) -> Type[Serializer]:
def serializer(self) -> type[Serializer]:
"""Get serializer for this model"""
raise NotImplementedError
@ -505,7 +505,7 @@ class PropertyMapping(SerializerModel, ManagedModel):
raise NotImplementedError
@property
def serializer(self) -> Type[Serializer]:
def serializer(self) -> type[Serializer]:
"""Get serializer for this model"""
raise NotImplementedError

View File

@ -1,5 +1,5 @@
"""authentik core signals"""
from typing import TYPE_CHECKING, Type
from typing import TYPE_CHECKING
from django.contrib.auth.signals import user_logged_in, user_logged_out
from django.contrib.sessions.backends.cache import KEY_PREFIX
@ -62,7 +62,7 @@ def user_logged_out_session(sender, request: HttpRequest, user: "User", **_):
@receiver(pre_delete)
def authenticated_session_delete(sender: Type[Model], instance: "AuthenticatedSession", **_):
def authenticated_session_delete(sender: type[Model], instance: "AuthenticatedSession", **_):
"""Delete session when authenticated session is deleted"""
from authentik.core.models import AuthenticatedSession

View File

@ -1,6 +1,6 @@
"""Source decision helper"""
from enum import Enum
from typing import Any, Optional, Type
from typing import Any, Optional
from django.contrib import messages
from django.db import IntegrityError
@ -50,7 +50,7 @@ class SourceFlowManager:
identifier: str
connection_type: Type[UserSourceConnection] = UserSourceConnection
connection_type: type[UserSourceConnection] = UserSourceConnection
def __init__(
self,

View File

@ -1,6 +1,6 @@
"""authentik core models tests"""
from time import sleep
from typing import Callable, Type
from typing import Callable
from django.test import RequestFactory, TestCase
from django.utils.timezone import now
@ -27,7 +27,7 @@ class TestModels(TestCase):
self.assertFalse(token.is_expired)
def source_tester_factory(test_model: Type[Stage]) -> Callable:
def source_tester_factory(test_model: type[Stage]) -> Callable:
"""Test source"""
factory = RequestFactory()
@ -47,7 +47,7 @@ def source_tester_factory(test_model: Type[Stage]) -> Callable:
return tester
def provider_tester_factory(test_model: Type[Stage]) -> Callable:
def provider_tester_factory(test_model: type[Stage]) -> Callable:
"""Test provider"""
def tester(self: TestModels):

View File

@ -1,7 +1,7 @@
"""authentik crypto models"""
from binascii import hexlify
from hashlib import md5
from typing import Optional, Union
from typing import Optional
from uuid import uuid4
from cryptography.hazmat.backends import default_backend
@ -41,8 +41,8 @@ class CertificateKeyPair(ManagedModel, CreatedUpdatedModel):
)
_cert: Optional[Certificate] = None
_private_key: Optional[Union[RSAPrivateKey, EllipticCurvePrivateKey, Ed25519PrivateKey]] = None
_public_key: Optional[Union[RSAPublicKey, EllipticCurvePublicKey, Ed25519PublicKey]] = None
_private_key: Optional[RSAPrivateKey | EllipticCurvePrivateKey | Ed25519PrivateKey] = None
_public_key: Optional[RSAPublicKey | EllipticCurvePublicKey | Ed25519PublicKey] = None
@property
def certificate(self) -> Certificate:
@ -54,7 +54,7 @@ class CertificateKeyPair(ManagedModel, CreatedUpdatedModel):
return self._cert
@property
def public_key(self) -> Optional[Union[RSAPublicKey, EllipticCurvePublicKey, Ed25519PublicKey]]:
def public_key(self) -> Optional[RSAPublicKey | EllipticCurvePublicKey | Ed25519PublicKey]:
"""Get public key of the private key"""
if not self._public_key:
self._public_key = self.private_key.public_key()
@ -63,7 +63,7 @@ class CertificateKeyPair(ManagedModel, CreatedUpdatedModel):
@property
def private_key(
self,
) -> Optional[Union[RSAPrivateKey, EllipticCurvePrivateKey, Ed25519PrivateKey]]:
) -> Optional[RSAPrivateKey | EllipticCurvePrivateKey | Ed25519PrivateKey]:
"""Get python cryptography PrivateKey instance"""
if not self._private_key and self.key_data != "":
try:

View File

@ -19,7 +19,7 @@ def convert_user_to_json(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
Event = apps.get_model("authentik_events", "Event")
db_alias = schema_editor.connection.alias
for event in Event.objects.all():
for event in Event.objects.using(db_alias).all():
event.delete()
# Because event objects cannot be updated, we have to re-create them
event.pk = None

View File

@ -10,7 +10,7 @@ def convert_user_to_json(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
Event = apps.get_model("authentik_events", "Event")
db_alias = schema_editor.connection.alias
for event in Event.objects.all():
for event in Event.objects.using(db_alias).all():
event.delete()
# Because event objects cannot be updated, we have to re-create them
event.pk = None

View File

@ -4,7 +4,7 @@ from collections import Counter
from datetime import timedelta
from inspect import currentframe
from smtplib import SMTPException
from typing import TYPE_CHECKING, Optional, Type, Union
from typing import TYPE_CHECKING, Optional
from uuid import uuid4
from django.conf import settings
@ -190,7 +190,7 @@ class Event(ExpiringModel):
@staticmethod
def new(
action: Union[str, EventAction],
action: str | EventAction,
app: Optional[str] = None,
**kwargs,
) -> "Event":
@ -517,7 +517,7 @@ class NotificationWebhookMapping(PropertyMapping):
return "ak-property-mapping-notification-form"
@property
def serializer(self) -> Type["Serializer"]:
def serializer(self) -> type["Serializer"]:
from authentik.events.api.notification_mapping import NotificationWebhookMappingSerializer
return NotificationWebhookMappingSerializer

View File

@ -1,7 +1,7 @@
"""Flow models"""
from base64 import b64decode, b64encode
from pickle import dumps, loads # nosec
from typing import TYPE_CHECKING, Optional, Type
from typing import TYPE_CHECKING, Optional
from uuid import uuid4
from django.db import models
@ -63,7 +63,7 @@ class Stage(SerializerModel):
objects = InheritanceManager()
@property
def type(self) -> Type["StageView"]:
def type(self) -> type["StageView"]:
"""Return StageView class that implements logic for this stage"""
# This is a bit of a workaround, since we can't set class methods with setattr
if hasattr(self, "__in_memory_type"):
@ -86,7 +86,7 @@ class Stage(SerializerModel):
return f"Stage {self.name}"
def in_memory_stage(view: Type["StageView"]) -> Stage:
def in_memory_stage(view: type["StageView"]) -> Stage:
"""Creates an in-memory stage instance, based on a `view` as view."""
stage = Stage()
# Because we can't pickle a locally generated function,

View File

@ -1,5 +1,5 @@
"""base model tests"""
from typing import Callable, Type
from typing import Callable
from django.test import TestCase
@ -12,7 +12,7 @@ class TestModels(TestCase):
"""Generic model properties tests"""
def model_tester_factory(test_model: Type[Stage]) -> Callable:
def model_tester_factory(test_model: type[Stage]) -> Callable:
"""Test a form"""
def tester(self: TestModels):

View File

@ -1,5 +1,5 @@
"""stage view tests"""
from typing import Callable, Type
from typing import Callable
from django.test import RequestFactory, TestCase
@ -16,7 +16,7 @@ class TestViews(TestCase):
self.exec = FlowExecutorView(request=self.factory.get("/"))
def view_tester_factory(view_class: Type[StageView]) -> Callable:
def view_tester_factory(view_class: type[StageView]) -> Callable:
"""Test a form"""
def tester(self: TestViews):

View File

@ -2,7 +2,7 @@
from contextlib import contextmanager
from copy import deepcopy
from json import loads
from typing import Any, Type
from typing import Any
from dacite import from_dict
from dacite.exceptions import DaciteError
@ -87,7 +87,7 @@ class FlowImporter:
def _validate_single(self, entry: FlowBundleEntry) -> BaseSerializer:
"""Validate a single entry"""
model_app_label, model_name = entry.model.split(".")
model: Type[SerializerModel] = apps.get_model(model_app_label, model_name)
model: type[SerializerModel] = apps.get_model(model_app_label, model_name)
if not isinstance(model(), ALLOWED_MODELS):
raise EntryInvalidError(f"Model {model} not allowed")

View File

@ -1,5 +1,5 @@
"""base model tests"""
from typing import Callable, Type
from typing import Callable
from django.test import TestCase
from rest_framework.serializers import BaseSerializer
@ -13,7 +13,7 @@ class TestModels(TestCase):
"""Generic model properties tests"""
def model_tester_factory(test_model: Type[Stage]) -> Callable:
def model_tester_factory(test_model: type[Stage]) -> Callable:
"""Test a form"""
def tester(self: TestModels):

View File

@ -2,7 +2,6 @@
import os
from importlib import import_module
from pathlib import Path
from typing import Union
from django.conf import settings
from kubernetes.config.incluster_config import SERVICE_HOST_ENV_NAME
@ -30,7 +29,7 @@ def class_to_path(cls: type) -> str:
return f"{cls.__module__}.{cls.__name__}"
def path_to_class(path: Union[str, None]) -> Union[type, None]:
def path_to_class(path: str | None) -> type | None:
"""Import module and return class"""
if not path:
return None

View File

@ -1,5 +1,5 @@
"""Managed objects manager"""
from typing import Callable, Optional, Type
from typing import Callable, Optional
from structlog.stdlib import get_logger
@ -11,11 +11,11 @@ LOGGER = get_logger()
class EnsureOp:
"""Ensure operation, executed as part of an ObjectManager run"""
_obj: Type[ManagedModel]
_obj: type[ManagedModel]
_managed_uid: str
_kwargs: dict
def __init__(self, obj: Type[ManagedModel], managed_uid: str, **kwargs) -> None:
def __init__(self, obj: type[ManagedModel], managed_uid: str, **kwargs) -> None:
self._obj = obj
self._managed_uid = managed_uid
self._kwargs = kwargs
@ -32,7 +32,7 @@ class EnsureExists(EnsureOp):
def __init__(
self,
obj: Type[ManagedModel],
obj: type[ManagedModel],
managed_uid: str,
created_callback: Optional[Callable] = None,
**kwargs,

View File

@ -1,6 +1,5 @@
"""Kubernetes deployment controller"""
from io import StringIO
from typing import Type
from kubernetes.client import VersionApi, VersionInfo
from kubernetes.client.api_client import ApiClient
@ -54,7 +53,7 @@ class KubernetesClient(ApiClient, BaseClient):
class KubernetesController(BaseController):
"""Manage deployment of outpost in kubernetes"""
reconcilers: dict[str, Type[KubernetesObjectReconciler]]
reconcilers: dict[str, type[KubernetesObjectReconciler]]
reconcile_order: list[str]
client: KubernetesClient

View File

@ -2,7 +2,7 @@
from dataclasses import asdict, dataclass, field
from datetime import datetime
from os import environ
from typing import Iterable, Optional, Union
from typing import Iterable, Optional
from uuid import uuid4
from dacite import from_dict
@ -76,7 +76,7 @@ class OutpostConfig:
class OutpostModel(Model):
"""Base model for providers that need more objects than just themselves"""
def get_required_objects(self) -> Iterable[Union[models.Model, str]]:
def get_required_objects(self) -> Iterable[models.Model | str]:
"""Return a list of all required objects"""
return [self]
@ -375,9 +375,9 @@ class Outpost(ManagedModel):
Token.objects.filter(identifier=self.token_identifier).delete()
return self.token
def get_required_objects(self) -> Iterable[Union[models.Model, str]]:
def get_required_objects(self) -> Iterable[models.Model | str]:
"""Get an iterator of all objects the user needs read access to"""
objects: list[Union[models.Model, str]] = [
objects: list[models.Model | str] = [
self,
"authentik_events.add_event",
]
@ -404,7 +404,7 @@ class OutpostState:
channel_ids: list[str] = field(default_factory=list)
last_seen: Optional[datetime] = field(default=None)
version: Optional[str] = field(default=None)
version_should: Union[Version, LegacyVersion] = field(default=OUR_VERSION)
version_should: Version | LegacyVersion = field(default=OUR_VERSION)
build_hash: str = field(default="")
_outpost: Optional[Outpost] = field(default=None)

View File

@ -1,5 +1,5 @@
"""LDAP Provider"""
from typing import Iterable, Optional, Type, Union
from typing import Iterable, Optional
from django.db import models
from django.utils.translation import gettext_lazy as _
@ -78,7 +78,7 @@ class LDAPProvider(OutpostModel, Provider):
return "ak-provider-ldap-form"
@property
def serializer(self) -> Type[Serializer]:
def serializer(self) -> type[Serializer]:
from authentik.providers.ldap.api import LDAPProviderSerializer
return LDAPProviderSerializer
@ -86,7 +86,7 @@ class LDAPProvider(OutpostModel, Provider):
def __str__(self):
return f"LDAP Provider {self.name}"
def get_required_objects(self) -> Iterable[Union[models.Model, str]]:
def get_required_objects(self) -> Iterable[models.Model | str]:
required_models = [self, "authentik_core.view_user", "authentik_core.view_group"]
if self.certificate is not None:
required_models.append(self.certificate)

View File

@ -6,7 +6,7 @@ import time
from dataclasses import asdict, dataclass, field
from datetime import datetime
from hashlib import sha256
from typing import Any, Optional, Type
from typing import Any, Optional
from urllib.parse import urlparse
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePrivateKey
@ -112,7 +112,7 @@ class ScopeMapping(PropertyMapping):
return "ak-property-mapping-scope-form"
@property
def serializer(self) -> Type[Serializer]:
def serializer(self) -> type[Serializer]:
from authentik.providers.oauth2.api.scope import ScopeMappingSerializer
return ScopeMappingSerializer
@ -267,7 +267,7 @@ class OAuth2Provider(Provider):
return "ak-provider-oauth2-form"
@property
def serializer(self) -> Type[Serializer]:
def serializer(self) -> type[Serializer]:
from authentik.providers.oauth2.api.provider import OAuth2ProviderSerializer
return OAuth2ProviderSerializer

View File

@ -1,7 +1,7 @@
"""authentik proxy models"""
import string
from random import SystemRandom
from typing import Iterable, Optional, Type, Union
from typing import Iterable, Optional
from urllib.parse import urljoin
from django.db import models
@ -110,7 +110,7 @@ class ProxyProvider(OutpostModel, OAuth2Provider):
return "ak-provider-proxy-form"
@property
def serializer(self) -> Type[Serializer]:
def serializer(self) -> type[Serializer]:
from authentik.providers.proxy.api import ProxyProviderSerializer
return ProxyProviderSerializer
@ -138,7 +138,7 @@ class ProxyProvider(OutpostModel, OAuth2Provider):
def __str__(self):
return f"Proxy Provider {self.name}"
def get_required_objects(self) -> Iterable[Union[models.Model, str]]:
def get_required_objects(self) -> Iterable[models.Model | str]:
required_models = [self]
if self.certificate is not None:
required_models.append(self.certificate)

View File

@ -1,5 +1,5 @@
"""authentik saml_idp Models"""
from typing import Optional, Type
from typing import Optional
from django.db import models
from django.urls import reverse
@ -163,7 +163,7 @@ class SAMLProvider(Provider):
return None
@property
def serializer(self) -> Type[Serializer]:
def serializer(self) -> type[Serializer]:
from authentik.providers.saml.api import SAMLProviderSerializer
return SAMLProviderSerializer
@ -192,7 +192,7 @@ class SAMLPropertyMapping(PropertyMapping):
return "ak-property-mapping-saml-form"
@property
def serializer(self) -> Type[Serializer]:
def serializer(self) -> type[Serializer]:
from authentik.providers.saml.api import SAMLPropertyMappingSerializer
return SAMLPropertyMappingSerializer

View File

@ -1,7 +1,7 @@
"""SAML AuthNRequest Parser and dataclass"""
from base64 import b64decode
from dataclasses import dataclass
from typing import Optional, Union
from typing import Optional
from urllib.parse import quote_plus
import xmlsec
@ -54,9 +54,7 @@ class AuthNRequestParser:
def __init__(self, provider: SAMLProvider):
self.provider = provider
def _parse_xml(
self, decoded_xml: Union[str, bytes], relay_state: Optional[str]
) -> AuthNRequest:
def _parse_xml(self, decoded_xml: str | bytes, relay_state: Optional[str]) -> AuthNRequest:
root = ElementTree.fromstring(decoded_xml)
# http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf

View File

@ -1,6 +1,5 @@
"""authentik LDAP Models"""
from ssl import CERT_REQUIRED
from typing import Type
from django.db import models
from django.utils.translation import gettext_lazy as _
@ -101,7 +100,7 @@ class LDAPSource(Source):
return "ak-source-ldap-form"
@property
def serializer(self) -> Type[Serializer]:
def serializer(self) -> type[Serializer]:
from authentik.sources.ldap.api import LDAPSourceSerializer
return LDAPSourceSerializer
@ -157,7 +156,7 @@ class LDAPPropertyMapping(PropertyMapping):
return "ak-property-mapping-ldap-form"
@property
def serializer(self) -> Type[Serializer]:
def serializer(self) -> type[Serializer]:
from authentik.sources.ldap.api import LDAPPropertyMappingSerializer
return LDAPPropertyMappingSerializer

View File

@ -48,7 +48,7 @@ class OAuthSource(Source):
consumer_secret = models.TextField()
@property
def type(self) -> Type["SourceType"]:
def type(self) -> type["SourceType"]:
"""Return the provider instance for this source"""
from authentik.sources.oauth.types.manager import MANAGER
@ -58,6 +58,7 @@ class OAuthSource(Source):
def component(self) -> str:
return "ak-source-oauth-form"
# we're using Type[] instead of type[] here since type[] interferes with the property above
@property
def serializer(self) -> Type[Serializer]:
from authentik.sources.oauth.api.source import OAuthSourceSerializer

View File

@ -59,7 +59,7 @@ class SourceTypeManager:
"""Manager to hold all Source types."""
def __init__(self) -> None:
self.__sources: list[Type[SourceType]] = []
self.__sources: list[type[SourceType]] = []
def type(self):
"""Class decorator to register classes inline."""

View File

@ -1,5 +1,5 @@
"""OAuth Base views"""
from typing import Optional, Type
from typing import Optional
from django.http.request import HttpRequest
from structlog.stdlib import get_logger
@ -18,7 +18,7 @@ class OAuthClientMixin:
request: HttpRequest # Set by View class
client_class: Optional[Type[BaseOAuthClient]] = None
client_class: Optional[type[BaseOAuthClient]] = None
def get_client(self, source: OAuthSource, **kwargs) -> BaseOAuthClient:
"Get instance of the OAuth client for this source."

View File

@ -1,5 +1,4 @@
"""saml sp models"""
from typing import Type
from django.db import models
from django.http import HttpRequest
@ -150,7 +149,7 @@ class SAMLSource(Source):
return "ak-source-saml-form"
@property
def serializer(self) -> Type[Serializer]:
def serializer(self) -> type[Serializer]:
from authentik.sources.saml.api import SAMLSourceSerializer
return SAMLSourceSerializer

View File

@ -1,5 +1,5 @@
"""Duo stage"""
from typing import Optional, Type
from typing import Optional
from django.contrib.auth import get_user_model
from django.db import models
@ -28,7 +28,7 @@ class AuthenticatorDuoStage(ConfigurableStage, Stage):
return AuthenticatorDuoStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.authenticator_duo.stage import AuthenticatorDuoStageView
return AuthenticatorDuoStageView

View File

@ -1,5 +1,5 @@
"""OTP Time-based models"""
from typing import Optional, Type
from typing import Optional
from django.contrib.auth import get_user_model
from django.db import models
@ -132,7 +132,7 @@ class AuthenticatorSMSStage(ConfigurableStage, Stage):
return AuthenticatorSMSStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.authenticator_sms.stage import AuthenticatorSMSStageView
return AuthenticatorSMSStageView

View File

@ -1,5 +1,5 @@
"""Static Authenticator models"""
from typing import Optional, Type
from typing import Optional
from django.db import models
from django.utils.translation import gettext_lazy as _
@ -22,7 +22,7 @@ class AuthenticatorStaticStage(ConfigurableStage, Stage):
return AuthenticatorStaticStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.authenticator_static.stage import AuthenticatorStaticStageView
return AuthenticatorStaticStageView

View File

@ -1,5 +1,5 @@
"""OTP Time-based models"""
from typing import Optional, Type
from typing import Optional
from django.db import models
from django.utils.translation import gettext_lazy as _
@ -29,7 +29,7 @@ class AuthenticatorTOTPStage(ConfigurableStage, Stage):
return AuthenticatorTOTPStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.authenticator_totp.stage import AuthenticatorTOTPStageView
return AuthenticatorTOTPStageView

View File

@ -1,5 +1,4 @@
"""Authenticator Validation Stage"""
from typing import Type
from django.contrib.postgres.fields.array import ArrayField
from django.db import models
@ -67,7 +66,7 @@ class AuthenticatorValidateStage(Stage):
return AuthenticatorValidateStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.authenticator_validate.stage import AuthenticatorValidateStageView
return AuthenticatorValidateStageView

View File

@ -1,5 +1,5 @@
"""WebAuthn stage"""
from typing import Optional, Type
from typing import Optional
from django.contrib.auth import get_user_model
from django.db import models
@ -46,7 +46,7 @@ class AuthenticateWebAuthnStage(ConfigurableStage, Stage):
return AuthenticateWebAuthnStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.authenticator_webauthn.stage import AuthenticatorWebAuthnStageView
return AuthenticatorWebAuthnStageView

View File

@ -1,5 +1,4 @@
"""authentik captcha stage"""
from typing import Type
from django.db import models
from django.utils.translation import gettext_lazy as _
@ -26,7 +25,7 @@ class CaptchaStage(Stage):
return CaptchaStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.captcha.stage import CaptchaStageView
return CaptchaStageView

View File

@ -1,5 +1,4 @@
"""authentik consent stage"""
from typing import Type
from django.db import models
from django.utils.translation import gettext_lazy as _
@ -39,7 +38,7 @@ class ConsentStage(Stage):
return ConsentStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.consent.stage import ConsentStageView
return ConsentStageView

View File

@ -1,5 +1,4 @@
"""deny stage models"""
from typing import Type
from django.utils.translation import gettext_lazy as _
from django.views import View
@ -18,7 +17,7 @@ class DenyStage(Stage):
return DenyStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.deny.stage import DenyStageView
return DenyStageView

View File

@ -1,5 +1,4 @@
"""dummy stage models"""
from typing import Type
from django.utils.translation import gettext as _
from django.views import View
@ -20,7 +19,7 @@ class DummyStage(Stage):
return DummyStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.dummy.stage import DummyStageView
return DummyStageView

View File

@ -88,7 +88,7 @@ class EmailStage(Stage):
return EmailStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.email.stage import EmailStageView
return EmailStageView

View File

@ -1,5 +1,4 @@
"""identification stage models"""
from typing import Type
from django.contrib.postgres.fields import ArrayField
from django.db import models
@ -99,7 +98,7 @@ class IdentificationStage(Stage):
return IdentificationStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.identification.stage import IdentificationStageView
return IdentificationStageView

View File

@ -1,5 +1,4 @@
"""invitation stage models"""
from typing import Type
from uuid import uuid4
from django.db import models
@ -33,7 +32,7 @@ class InvitationStage(Stage):
return InvitationStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.invitation.stage import InvitationStageView
return InvitationStageView

View File

@ -1,5 +1,5 @@
"""password stage models"""
from typing import Optional, Type
from typing import Optional
from django.contrib.postgres.fields import ArrayField
from django.db import models
@ -54,7 +54,7 @@ class PasswordStage(ConfigurableStage, Stage):
return PasswordStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.password.stage import PasswordStageView
return PasswordStageView

View File

@ -1,5 +1,5 @@
"""prompt models"""
from typing import Any, Optional, Type
from typing import Any, Optional
from uuid import uuid4
from django.db import models
@ -146,7 +146,7 @@ class PromptStage(Stage):
return PromptStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.prompt.stage import PromptStageView
return PromptStageView

View File

@ -1,5 +1,4 @@
"""delete stage models"""
from typing import Type
from django.utils.translation import gettext_lazy as _
from django.views import View
@ -19,7 +18,7 @@ class UserDeleteStage(Stage):
return UserDeleteStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.user_delete.stage import UserDeleteStageView
return UserDeleteStageView

View File

@ -1,5 +1,4 @@
"""login stage models"""
from typing import Type
from django.db import models
from django.utils.translation import gettext_lazy as _
@ -30,7 +29,7 @@ class UserLoginStage(Stage):
return UserLoginStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.user_login.stage import UserLoginStageView
return UserLoginStageView

View File

@ -1,5 +1,4 @@
"""logout stage models"""
from typing import Type
from django.utils.translation import gettext_lazy as _
from django.views import View
@ -18,7 +17,7 @@ class UserLogoutStage(Stage):
return UserLogoutStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.user_logout.stage import UserLogoutStageView
return UserLogoutStageView

View File

@ -1,5 +1,4 @@
"""write stage models"""
from typing import Type
from django.db import models
from django.utils.translation import gettext_lazy as _
@ -34,7 +33,7 @@ class UserWriteStage(Stage):
return UserWriteStageSerializer
@property
def type(self) -> Type[View]:
def type(self) -> type[View]:
from authentik.stages.user_write.stage import UserWriteStageView
return UserWriteStageView