Apply the code reviewer suggestion of abstractmethod

This commit is contained in:
Willem Jiang
2026-04-26 20:31:06 +08:00
parent 16aedf459a
commit 653b7ae17a
2 changed files with 8 additions and 8 deletions
+2 -2
View File
@@ -12,12 +12,12 @@ class AuthProvider(ABC):
Returns User if authentication succeeds, None otherwise. Returns User if authentication succeeds, None otherwise.
""" """
... raise NotImplementedError
@abstractmethod @abstractmethod
async def get_user(self, user_id: str) -> "User | None": async def get_user(self, user_id: str) -> "User | None":
"""Retrieve user by ID.""" """Retrieve user by ID."""
... raise NotImplementedError
# Import User at runtime to avoid circular imports # Import User at runtime to avoid circular imports
@@ -35,7 +35,7 @@ class UserRepository(ABC):
Raises: Raises:
ValueError: If email already exists ValueError: If email already exists
""" """
... raise NotImplementedError
@abstractmethod @abstractmethod
async def get_user_by_id(self, user_id: str) -> User | None: async def get_user_by_id(self, user_id: str) -> User | None:
@@ -47,7 +47,7 @@ class UserRepository(ABC):
Returns: Returns:
User if found, None otherwise User if found, None otherwise
""" """
... raise NotImplementedError
@abstractmethod @abstractmethod
async def get_user_by_email(self, email: str) -> User | None: async def get_user_by_email(self, email: str) -> User | None:
@@ -59,7 +59,7 @@ class UserRepository(ABC):
Returns: Returns:
User if found, None otherwise User if found, None otherwise
""" """
... raise NotImplementedError
@abstractmethod @abstractmethod
async def update_user(self, user: User) -> User: async def update_user(self, user: User) -> User:
@@ -81,12 +81,12 @@ class UserRepository(ABC):
@abstractmethod @abstractmethod
async def count_users(self) -> int: async def count_users(self) -> int:
"""Return total number of registered users.""" """Return total number of registered users."""
... raise NotImplementedError
@abstractmethod @abstractmethod
async def count_admin_users(self) -> int: async def count_admin_users(self) -> int:
"""Return number of users with system_role == 'admin'.""" """Return number of users with system_role == 'admin'."""
... raise NotImplementedError
@abstractmethod @abstractmethod
async def get_user_by_oauth(self, provider: str, oauth_id: str) -> User | None: async def get_user_by_oauth(self, provider: str, oauth_id: str) -> User | None:
@@ -99,4 +99,4 @@ class UserRepository(ABC):
Returns: Returns:
User if found, None otherwise User if found, None otherwise
""" """
... raise NotImplementedError