From d2a660187c8716d83f5611178aa692b9f00bb46e Mon Sep 17 00:00:00 2001 From: SKairinos Date: Fri, 29 Sep 2023 14:08:50 +0100 Subject: [PATCH] remove inferred return types --- codeforlife/user/auth/backends/email_and_password.py | 5 ++--- codeforlife/user/auth/backends/otp.py | 5 ++--- codeforlife/user/auth/backends/token.py | 5 ++--- codeforlife/user/auth/backends/user_id_and_login_id.py | 5 ++--- .../user/auth/backends/username_and_password_and_class_id.py | 5 ++--- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/codeforlife/user/auth/backends/email_and_password.py b/codeforlife/user/auth/backends/email_and_password.py index 9aa7e625..934fa29b 100644 --- a/codeforlife/user/auth/backends/email_and_password.py +++ b/codeforlife/user/auth/backends/email_and_password.py @@ -1,7 +1,6 @@ import typing as t from django.contrib.auth.backends import BaseBackend -from django.contrib.auth.base_user import AbstractBaseUser from ....request import WSGIRequest from ...models import User @@ -14,7 +13,7 @@ def authenticate( email: t.Optional[str] = None, password: t.Optional[str] = None, **kwargs - ) -> t.Optional[AbstractBaseUser]: + ): if email is None or password is None: return @@ -25,7 +24,7 @@ def authenticate( except User.DoesNotExist: return - def get_user(self, user_id: int) -> t.Optional[AbstractBaseUser]: + def get_user(self, user_id: int): try: return User.objects.get(id=user_id) except User.DoesNotExist: diff --git a/codeforlife/user/auth/backends/otp.py b/codeforlife/user/auth/backends/otp.py index 943980a8..40c2f565 100644 --- a/codeforlife/user/auth/backends/otp.py +++ b/codeforlife/user/auth/backends/otp.py @@ -2,7 +2,6 @@ import pyotp from django.contrib.auth.backends import BaseBackend -from django.contrib.auth.base_user import AbstractBaseUser from django.utils import timezone from ....request import WSGIRequest @@ -15,7 +14,7 @@ def authenticate( request: WSGIRequest, otp: t.Optional[str] = None, **kwargs, - ) -> t.Optional[AbstractBaseUser]: + ): # Avoid near misses by getting the timestamp before any processing. now = timezone.now() @@ -47,7 +46,7 @@ def authenticate( return request.user - def get_user(self, user_id: int) -> t.Optional[AbstractBaseUser]: + def get_user(self, user_id: int): try: return User.objects.get(id=user_id) except User.DoesNotExist: diff --git a/codeforlife/user/auth/backends/token.py b/codeforlife/user/auth/backends/token.py index 06f94f92..d0b23850 100644 --- a/codeforlife/user/auth/backends/token.py +++ b/codeforlife/user/auth/backends/token.py @@ -1,7 +1,6 @@ import typing as t from django.contrib.auth.backends import BaseBackend -from django.contrib.auth.base_user import AbstractBaseUser from ....request import WSGIRequest from ...models import AuthFactor, User @@ -13,7 +12,7 @@ def authenticate( request: WSGIRequest, token: t.Optional[str] = None, **kwargs, - ) -> t.Optional[AbstractBaseUser]: + ): if ( token is None or not isinstance(request.user, User) @@ -27,7 +26,7 @@ def authenticate( if backup_token.check_token(token): return request.user - def get_user(self, user_id: int) -> t.Optional[AbstractBaseUser]: + def get_user(self, user_id: int): try: return User.objects.get(id=user_id) except User.DoesNotExist: diff --git a/codeforlife/user/auth/backends/user_id_and_login_id.py b/codeforlife/user/auth/backends/user_id_and_login_id.py index 5c746ed5..15da47ca 100644 --- a/codeforlife/user/auth/backends/user_id_and_login_id.py +++ b/codeforlife/user/auth/backends/user_id_and_login_id.py @@ -3,7 +3,6 @@ from common.helpers.generators import get_hashed_login_id from common.models import Student from django.contrib.auth.backends import BaseBackend -from django.contrib.auth.base_user import AbstractBaseUser from ....request import WSGIRequest from ...models import User @@ -16,7 +15,7 @@ def authenticate( user_id: t.Optional[int] = None, login_id: t.Optional[str] = None, **kwargs - ) -> t.Optional[AbstractBaseUser]: + ): if user_id is None or login_id is None: return @@ -31,7 +30,7 @@ def authenticate( ): return user - def get_user(self, user_id: int) -> t.Optional[AbstractBaseUser]: + def get_user(self, user_id: int): try: return User.objects.get(id=user_id) except User.DoesNotExist: diff --git a/codeforlife/user/auth/backends/username_and_password_and_class_id.py b/codeforlife/user/auth/backends/username_and_password_and_class_id.py index c3c338dd..0a1c8cd1 100644 --- a/codeforlife/user/auth/backends/username_and_password_and_class_id.py +++ b/codeforlife/user/auth/backends/username_and_password_and_class_id.py @@ -1,7 +1,6 @@ import typing as t from django.contrib.auth.backends import BaseBackend -from django.contrib.auth.base_user import AbstractBaseUser from ....request import WSGIRequest from ...models import User @@ -15,7 +14,7 @@ def authenticate( password: t.Optional[str] = None, class_id: t.Optional[str] = None, **kwargs - ) -> t.Optional[AbstractBaseUser]: + ): if username is None or password is None or class_id is None: return @@ -29,7 +28,7 @@ def authenticate( except User.DoesNotExist: return - def get_user(self, user_id: int) -> t.Optional[AbstractBaseUser]: + def get_user(self, user_id: int): try: return User.objects.get(id=user_id) except User.DoesNotExist: