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

View File

@ -12,12 +12,12 @@ class AuthProvider(ABC):
Returns User if authentication succeeds, None otherwise.
"""
...
raise NotImplementedError
@abstractmethod
async def get_user(self, user_id: str) -> "User | None":
"""Retrieve user by ID."""
...
raise NotImplementedError
# Import User at runtime to avoid circular imports

View File

@ -35,7 +35,7 @@ class UserRepository(ABC):
Raises:
ValueError: If email already exists
"""
...
raise NotImplementedError
@abstractmethod
async def get_user_by_id(self, user_id: str) -> User | None:
@ -47,7 +47,7 @@ class UserRepository(ABC):
Returns:
User if found, None otherwise
"""
...
raise NotImplementedError
@abstractmethod
async def get_user_by_email(self, email: str) -> User | None:
@ -59,7 +59,7 @@ class UserRepository(ABC):
Returns:
User if found, None otherwise
"""
...
raise NotImplementedError
@abstractmethod
async def update_user(self, user: User) -> User:
@ -81,12 +81,12 @@ class UserRepository(ABC):
@abstractmethod
async def count_users(self) -> int:
"""Return total number of registered users."""
...
raise NotImplementedError
@abstractmethod
async def count_admin_users(self) -> int:
"""Return number of users with system_role == 'admin'."""
...
raise NotImplementedError
@abstractmethod
async def get_user_by_oauth(self, provider: str, oauth_id: str) -> User | None:
@ -99,4 +99,4 @@ class UserRepository(ABC):
Returns:
User if found, None otherwise
"""
...
raise NotImplementedError