From 1f8fb8188a39478f10738ac8179646986ec1ca7c Mon Sep 17 00:00:00 2001 From: Guillaume Tucker Date: Fri, 10 Nov 2023 13:15:38 +0100 Subject: [PATCH] api.user_manager: call UserManager parent with all arguments Rework the UserManager constructor to call the parent class with all the arguments passed using the sandard idiom. The arguments aren't used in the constructor, so this makes it entirely generic, safer and future-proof. Signed-off-by: Guillaume Tucker --- api/user_manager.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/api/user_manager.py b/api/user_manager.py index 39347b82..c7dee1a7 100644 --- a/api/user_manager.py +++ b/api/user_manager.py @@ -10,11 +10,9 @@ from fastapi.security import OAuth2PasswordRequestForm from fastapi_users import BaseUserManager from fastapi_users.db import ( - BaseUserDatabase, BeanieUserDatabase, ObjectIDIDMixin, ) -from fastapi_users.password import PasswordHelperProtocol from beanie import PydanticObjectId import jinja2 from .user_models import User @@ -28,14 +26,12 @@ class UserManager(ObjectIDIDMixin, BaseUserManager[User, PydanticObjectId]): reset_password_token_secret = settings.secret_key verification_token_secret = settings.secret_key - def __init__(self, user_db: BaseUserDatabase[User, PydanticObjectId], - password_helper: PasswordHelperProtocol | None = None): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) self._email_sender = None self._template_env = jinja2.Environment( - loader=jinja2.FileSystemLoader( - "./templates/") - ) - super().__init__(user_db, password_helper) + loader=jinja2.FileSystemLoader("./templates/") + ) @property def email_sender(self):