Skip to content

Commit d3356fb

Browse files
committed
update pydantic models to match whitespace
1 parent cada67d commit d3356fb

6 files changed

Lines changed: 96 additions & 75 deletions

File tree

qwave-server/src/qwave/api/albums.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,28 @@
1313
router = APIRouter()
1414

1515
class AlbumSummary(BaseModel):
16-
id: int
17-
title: str
16+
id: int
17+
title: str
1818
release_date: Optional[str]
1919
album_artist: Optional[dict]
20-
track_count: int
20+
track_count: int
2121

2222
class TrackInAlbum(BaseModel):
23-
id: int
24-
title: str
23+
id: int
24+
title: str
2525
track_number: Optional[int]
26-
duration: int
27-
artists: List[dict]
26+
duration: int
27+
artists: List[dict]
2828

2929
class AlbumDetail(BaseModel):
30-
id: int
31-
title: str
30+
id: int
31+
title: str
3232
release_date: Optional[str]
3333
album_artist: Optional[dict]
34-
tracks: List[TrackInAlbum]
34+
tracks: List[TrackInAlbum]
3535

3636
class UpdateAlbumRequest(BaseModel):
37-
title: Optional[str] = Field(None, min_length = 1, max_length = 255)
37+
title: Optional[str] = Field(None, min_length = 1, max_length = 255)
3838
release_date: Optional[str] = None # ISO date string
3939

4040
@router.get("", response_model = dict)

qwave-server/src/qwave/api/artists.py

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,51 +11,43 @@
1111
router = APIRouter()
1212

1313
class ArtistSummary(BaseModel):
14-
id: int
15-
name: str
16-
track_count: int
17-
album_count: int
18-
19-
class Config:
20-
from_attributes = True
14+
model_config = {"from_attributes": True}
15+
id: int
16+
name: str
17+
track_count: int
18+
album_count: int
2119

2220
class ArtistDetail(BaseModel):
23-
id: int
24-
name: str
25-
track_count: int
26-
album_count: int
27-
28-
class Config:
29-
from_attributes = True
21+
model_config = {"from_attributes": True}
22+
id: int
23+
name: str
24+
track_count: int
25+
album_count: int
3026

3127
class ArtistListResponse(BaseModel):
32-
artists: List[ArtistSummary]
33-
total: int
28+
artists: List[ArtistSummary]
29+
total: int
3430

3531
class TrackSummary(BaseModel):
36-
id: int
37-
title: str
38-
duration: float
39-
album: Optional[dict]
40-
41-
class Config:
42-
from_attributes = True
32+
model_config = {"from_attributes": True}
33+
id: int
34+
title: str
35+
duration: float
36+
album: Optional[dict]
4337

4438
class TracksResponse(BaseModel):
45-
tracks: List[TrackSummary]
46-
total: int
39+
tracks: List[TrackSummary]
40+
total: int
4741

4842
class AlbumSummary(BaseModel):
49-
id: int
50-
title: str
51-
release_date: Optional[str]
52-
track_count: int
53-
54-
class Config:
55-
from_attributes = True
43+
model_config = {"from_attributes": True}
44+
id: int
45+
title: str
46+
release_date: Optional[str]
47+
track_count: int
5648

5749
class AlbumsResponse(BaseModel):
58-
albums: List[AlbumSummary]
50+
albums: List[AlbumSummary]
5951

6052
@router.get("", response_model = ArtistListResponse)
6153
def list_artists(

qwave-server/src/qwave/api/auth.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,26 @@
1111
# endpoints: /register /login /logout /me
1212

1313
class RegisterRequest(BaseModel):
14-
username: str = Field(..., min_length = 3, max_length = 255)
15-
password: str = Field(..., min_length = 4)
14+
username: str = Field(..., min_length = 3, max_length = 255)
15+
password: str = Field(..., min_length = 4)
1616

1717
class LoginRequest(BaseModel):
18-
username: str
19-
password: str
18+
username: str
19+
password: str
2020

2121
class UserResponse(BaseModel):
22-
user_id: int
23-
username: str
24-
created_at: str
25-
26-
class Config:
27-
from_attributes = True
22+
model_config = {"from_attributes": True}
23+
user_id: int
24+
username: str
25+
created_at: str
2826

2927
class LoginResponse(BaseModel):
30-
token: str
31-
user_id: int
32-
expires_at: str
28+
token: str
29+
user_id: int
30+
expires_at: str
3331

3432
class MessageResponse(BaseModel):
35-
message: str
33+
message: str
3634

3735

3836
def get_current_token(authorization: str = Header(None)) -> str:

qwave-server/src/qwave/api/genres.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,18 @@
1010
router = APIRouter()
1111

1212
class CreateGenreRequest(BaseModel):
13-
name: str = Field(..., min_length = 1, max_length = 128)
13+
name: str = Field(..., min_length = 1, max_length = 128)
1414

1515
class GenreSummary(BaseModel):
16-
id: int
17-
name: str
18-
track_count: int
16+
id: int
17+
name: str
18+
track_count: int
1919

2020
class GenreResponse(BaseModel):
21-
id: int
22-
name: str
21+
model_config = {"from_attributes": True}
22+
id: int
23+
name: str
2324

24-
class Config:
25-
from_attributes = True
26-
2725
@router.get("", response_model = dict)
2826
def list_genres(
2927
user = Depends(get_current_user),

qwave-server/src/qwave/api/server.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
# /info /config
99

1010
class ServerInfoResponse(BaseModel):
11-
name: str
12-
theme_colors: dict
13-
logo_url: Optional[str]
14-
background_url: Optional[str]
11+
name: str
12+
theme_colors: dict
13+
logo_url: Optional[str]
14+
background_url: Optional[str]
1515

1616
class ServerConfigResponse(BaseModel):
17-
opus_bitrate: int
18-
acoustid_enabled: bool
17+
opus_bitrate: int
18+
acoustid_enabled: bool
1919
max_upload_size_mb: int
2020

2121
@router.get("/info", response_model = ServerInfoResponse)

qwave-server/src/qwave/api/tracks.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,39 @@
88

99
router = APIRouter()
1010

11+
# =========================== table item model thingies
1112
class ArtistInfo(BaseModel):
12-
id: int
13-
name:
13+
id: int
14+
name: str
15+
is_primary: bool
16+
17+
class AlbumInfo(BaseModel):
18+
id: int
19+
title: str
20+
release_date: Optional[str] = None
21+
22+
class GenreInfo(BaseModel):
23+
id: int
24+
name: str
25+
26+
class UserInfo(BaseModel):
27+
id: int
28+
username: str
29+
30+
# ========================== track responsesssssssssss
31+
class TrackSummary(BaseModel):
32+
id: int
33+
title: str
34+
duration: int
35+
artists: List[ArtistInfo]
36+
album: Optional[AlbumInfo]
37+
38+
class abc(BaseModel):
39+
abc: int
40+
41+
42+
# ===========
43+
class UpdateTrackResponse(BaseModel):
44+
id: int
45+
updated_fields: List[str]
46+
track: dict # maybe make this a model?

0 commit comments

Comments
 (0)