From e4f0613fab14d9ea0a7e1429e8cb6b38779d02c2 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 18 Feb 2021 13:53:57 +0100 Subject: [PATCH] *: replace tuple and set from typing with normal --- authentik/api/auth.py | 4 ++-- authentik/outposts/controllers/docker.py | 3 +-- authentik/providers/oauth2/utils.py | 4 ++-- authentik/providers/oauth2/views/authorize.py | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/authentik/api/auth.py b/authentik/api/auth.py index 2ee8fecad..dc51dcaae 100644 --- a/authentik/api/auth.py +++ b/authentik/api/auth.py @@ -1,7 +1,7 @@ """API Authentication""" from base64 import b64decode from binascii import Error -from typing import Any, Optional, Tuple, Union +from typing import Any, Optional, Union from rest_framework.authentication import BaseAuthentication, get_authorization_header from rest_framework.request import Request @@ -44,7 +44,7 @@ def token_from_header(raw_header: bytes) -> Optional[Token]: class AuthentikTokenAuthentication(BaseAuthentication): """Token-based authentication using HTTP Basic authentication""" - def authenticate(self, request: Request) -> Union[Tuple[User, Any], None]: + def authenticate(self, request: Request) -> Union[tuple[User, Any], None]: """Token-based authentication using HTTP Basic authentication""" auth = get_authorization_header(request) diff --git a/authentik/outposts/controllers/docker.py b/authentik/outposts/controllers/docker.py index a4c57b3e5..d87b99656 100644 --- a/authentik/outposts/controllers/docker.py +++ b/authentik/outposts/controllers/docker.py @@ -1,6 +1,5 @@ """Docker controller""" from time import sleep -from typing import Tuple from django.conf import settings from docker import DockerClient @@ -55,7 +54,7 @@ class DockerController(BaseController): return True return False - def _get_container(self) -> Tuple[Container, bool]: + def _get_container(self) -> tuple[Container, bool]: container_name = f"authentik-proxy-{self.outpost.uuid.hex}" try: return self.client.containers.get(container_name), False diff --git a/authentik/providers/oauth2/utils.py b/authentik/providers/oauth2/utils.py index a14d408ed..59334ce1d 100644 --- a/authentik/providers/oauth2/utils.py +++ b/authentik/providers/oauth2/utils.py @@ -2,7 +2,7 @@ import re from base64 import b64decode from binascii import Error -from typing import Optional, Tuple +from typing import Optional from django.http import HttpRequest, HttpResponse, JsonResponse from django.utils.cache import patch_vary_headers @@ -68,7 +68,7 @@ def extract_access_token(request: HttpRequest) -> Optional[str]: return None -def extract_client_auth(request: HttpRequest) -> Tuple[str, str]: +def extract_client_auth(request: HttpRequest) -> tuple[str, str]: """ Get client credentials using HTTP Basic Authentication method. Or try getting parameters via POST. diff --git a/authentik/providers/oauth2/views/authorize.py b/authentik/providers/oauth2/views/authorize.py index 1a8e2e3a1..aacafb8f4 100644 --- a/authentik/providers/oauth2/views/authorize.py +++ b/authentik/providers/oauth2/views/authorize.py @@ -1,7 +1,7 @@ """authentik OAuth2 Authorization views""" from dataclasses import dataclass, field from datetime import timedelta -from typing import Optional, Set +from typing import Optional from urllib.parse import parse_qs, urlencode, urlsplit, urlunsplit from uuid import uuid4 @@ -72,7 +72,7 @@ class OAuthAuthorizationParams: scope: list[str] state: str nonce: Optional[str] - prompt: Set[str] + prompt: set[str] grant_type: str provider: OAuth2Provider = field(default_factory=OAuth2Provider)