*: replace tuple and set from typing with normal

This commit is contained in:
Jens Langhammer 2021-02-18 13:53:57 +01:00
parent ecff810021
commit e4f0613fab
4 changed files with 7 additions and 8 deletions

View file

@ -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)

View file

@ -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

View file

@ -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.

View file

@ -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)