fix: Lint fixes of core, models and schemas
All checks were successful
Backend CI / test (push) Successful in 4m5s
All checks were successful
Backend CI / test (push) Successful in 4m5s
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from collections.abc import AsyncGenerator
|
||||
from collections.abc import AsyncGenerator, Callable
|
||||
|
||||
from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine
|
||||
from sqlmodel import SQLModel
|
||||
@@ -38,9 +38,9 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
||||
await session.close()
|
||||
|
||||
|
||||
def get_session_factory():
|
||||
def get_session_factory() -> Callable[[], AsyncSession]:
|
||||
"""Get a session factory function for services."""
|
||||
def session_factory():
|
||||
def session_factory() -> AsyncSession:
|
||||
return AsyncSession(engine)
|
||||
return session_factory
|
||||
|
||||
|
||||
@@ -135,8 +135,6 @@ async def get_current_user_api_token(
|
||||
detail="Account is deactivated",
|
||||
)
|
||||
|
||||
return user
|
||||
|
||||
except HTTPException:
|
||||
# Re-raise HTTPExceptions without wrapping them
|
||||
raise
|
||||
@@ -146,6 +144,8 @@ async def get_current_user_api_token(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Could not validate API token",
|
||||
) from e
|
||||
else:
|
||||
return user
|
||||
|
||||
|
||||
async def get_current_user_flexible(
|
||||
|
||||
@@ -17,7 +17,8 @@ class CreditTransaction(BaseModel, table=True):
|
||||
|
||||
user_id: int = Field(foreign_key="user.id", nullable=False)
|
||||
action_type: str = Field(nullable=False)
|
||||
amount: int = Field(nullable=False) # Negative for deductions, positive for additions
|
||||
# Negative for deductions, positive for additions
|
||||
amount: int = Field(nullable=False)
|
||||
balance_before: int = Field(nullable=False)
|
||||
balance_after: int = Field(nullable=False)
|
||||
description: str = Field(nullable=False)
|
||||
|
||||
@@ -25,7 +25,8 @@ class Extraction(BaseModel, table=True):
|
||||
status: str = Field(nullable=False, default="pending")
|
||||
error: str | None = Field(default=None)
|
||||
|
||||
# constraints - only enforce uniqueness when both service and service_id are not null
|
||||
# constraints - only enforce uniqueness when both service and service_id
|
||||
# are not null
|
||||
__table_args__ = ()
|
||||
|
||||
# relationships
|
||||
|
||||
@@ -28,25 +28,16 @@ from .playlist import (
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
# Auth schemas
|
||||
"ApiTokenRequest",
|
||||
"ApiTokenResponse",
|
||||
"ApiTokenStatusResponse",
|
||||
"AuthResponse",
|
||||
"TokenResponse",
|
||||
"UserLoginRequest",
|
||||
"UserRegisterRequest",
|
||||
"UserResponse",
|
||||
# Common schemas
|
||||
"HealthResponse",
|
||||
"MessageResponse",
|
||||
"StatusResponse",
|
||||
# Player schemas
|
||||
"PlayerModeRequest",
|
||||
"PlayerSeekRequest",
|
||||
"PlayerStateResponse",
|
||||
"PlayerVolumeRequest",
|
||||
# Playlist schemas
|
||||
"PlaylistAddSoundRequest",
|
||||
"PlaylistCreateRequest",
|
||||
"PlaylistReorderRequest",
|
||||
@@ -54,4 +45,9 @@ __all__ = [
|
||||
"PlaylistSoundResponse",
|
||||
"PlaylistStatsResponse",
|
||||
"PlaylistUpdateRequest",
|
||||
"StatusResponse",
|
||||
"TokenResponse",
|
||||
"UserLoginRequest",
|
||||
"UserRegisterRequest",
|
||||
"UserResponse",
|
||||
]
|
||||
|
||||
@@ -40,7 +40,8 @@ class PlaylistResponse(BaseModel):
|
||||
def from_playlist(cls, playlist: Playlist) -> "PlaylistResponse":
|
||||
"""Create response from playlist model."""
|
||||
if playlist.id is None:
|
||||
raise ValueError("Playlist ID cannot be None")
|
||||
msg = "Playlist ID cannot be None"
|
||||
raise ValueError(msg)
|
||||
return cls(
|
||||
id=playlist.id,
|
||||
name=playlist.name,
|
||||
@@ -70,7 +71,8 @@ class PlaylistSoundResponse(BaseModel):
|
||||
def from_sound(cls, sound: Sound) -> "PlaylistSoundResponse":
|
||||
"""Create response from sound model."""
|
||||
if sound.id is None:
|
||||
raise ValueError("Sound ID cannot be None")
|
||||
msg = "Sound ID cannot be None"
|
||||
raise ValueError(msg)
|
||||
return cls(
|
||||
id=sound.id,
|
||||
name=sound.name,
|
||||
|
||||
Reference in New Issue
Block a user