3
3
import datetime
4
4
import logging
5
5
from pathlib import Path
6
- from typing import TYPE_CHECKING , List , Optional , Tuple , Type , TypeVar , cast
6
+ from typing import TYPE_CHECKING , Optional , TypeVar , cast
7
7
8
8
import sqlalchemy as sa
9
9
from sqlalchemy import Column , Date , Integer , String , and_ , or_
@@ -46,11 +46,11 @@ class Album(LibItem, SABase):
46
46
artist (str): AKA albumartist.
47
47
date (datetime.date): Album release date.
48
48
disc_total (int): Number of discs in the album.
49
- extras (List [Extra]): Extra non-track files associated with the album.
49
+ extras (list [Extra]): Extra non-track files associated with the album.
50
50
mb_album_id (str): Musicbrainz album aka release id.
51
51
path (Path): Filesystem path of the album directory.
52
52
title (str)
53
- tracks (List [Track]): Album's corresponding tracks.
53
+ tracks (list [Track]): Album's corresponding tracks.
54
54
year (int): Album release year.
55
55
"""
56
56
@@ -64,13 +64,13 @@ class Album(LibItem, SABase):
64
64
path : Path = cast (Path , Column (PathType , nullable = False , unique = True ))
65
65
title : str = cast (str , Column (String , nullable = False ))
66
66
67
- tracks : "List[ Track]" = relationship (
67
+ tracks : list [ " Track" ] = relationship (
68
68
"Track" ,
69
69
back_populates = "album_obj" ,
70
70
cascade = "all, delete-orphan" ,
71
71
collection_class = list ,
72
72
)
73
- extras : "List[ Extra]" = relationship (
73
+ extras : list [ " Extra" ] = relationship (
74
74
"Extra" ,
75
75
back_populates = "album_obj" ,
76
76
cascade = "all, delete-orphan" ,
@@ -109,7 +109,7 @@ def __init__(
109
109
log .debug (f"Album created. [album={ self !r} ]" )
110
110
111
111
@classmethod
112
- def from_dir (cls : Type [A ], album_path : Path ) -> A :
112
+ def from_dir (cls : type [A ], album_path : Path ) -> A :
113
113
"""Creates an album from a directory.
114
114
115
115
Args:
@@ -149,7 +149,7 @@ def from_dir(cls: Type[A], album_path: Path) -> A:
149
149
log .debug (f"Album created from directory. [dir={ album_path } , { album = !r} ]" )
150
150
return album
151
151
152
- def fields (self ) -> Tuple [str , ...]:
152
+ def fields (self ) -> tuple [str , ...]:
153
153
"""Returns the public fields, or non-method attributes, of an Album."""
154
154
return (
155
155
"artist" ,
@@ -228,7 +228,7 @@ def merge(self, other: "Album", overwrite: bool = False) -> None:
228
228
if other_value and (overwrite or (not overwrite and not self_value )):
229
229
setattr (self , field , other_value )
230
230
231
- new_tracks : List [ " Track" ] = []
231
+ new_tracks : list [ Track ] = []
232
232
for other_track in other .tracks :
233
233
conflict_track = self .get_track (other_track .track_num , other_track .disc )
234
234
if conflict_track :
@@ -237,7 +237,7 @@ def merge(self, other: "Album", overwrite: bool = False) -> None:
237
237
new_tracks .append (other_track )
238
238
self .tracks .extend (new_tracks )
239
239
240
- new_extras : List [ " Extra" ] = []
240
+ new_extras : list [ Extra ] = []
241
241
for other_extra in other .extras :
242
242
conflict_extra = self .get_extra (other_extra .filename )
243
243
if conflict_extra and overwrite :
0 commit comments