Skip to content

Commit

Permalink
remove inferred return types
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Sep 29, 2023
1 parent fd151e6 commit d2a6601
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
5 changes: 2 additions & 3 deletions codeforlife/user/auth/backends/email_and_password.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions codeforlife/user/auth/backends/otp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()

Expand Down Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions codeforlife/user/auth/backends/token.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand All @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions codeforlife/user/auth/backends/user_id_and_login_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -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:
Expand Down

0 comments on commit d2a6601

Please sign in to comment.