Use basedpyright refactor
This commit is contained in:
@@ -25,14 +25,14 @@ def add_tema_to_tema_in_set(tema_in_set: playlists.TemaInSet) -> playlists.TemaI
|
||||
return tema_in_set
|
||||
|
||||
|
||||
def get_playlist(session_id: int, con: Optional[Connection] = None) -> playlists.Playlist:
|
||||
def get_playlist(session_id: int, con: Connection | None = None) -> playlists.Playlist:
|
||||
return playlists.Playlist.from_playlist_entries(
|
||||
session_id=session_id,
|
||||
entries=list(query.get_playlist_entries(session_id=session_id, con=con))
|
||||
)
|
||||
|
||||
|
||||
def add_set(session_id: int, con: Optional[Connection] = None) -> playlists.Set:
|
||||
def add_set(session_id: int, con: Connection | None = None) -> playlists.Set:
|
||||
with get_connection(con) as con:
|
||||
curr_playlist = get_playlist(session_id=session_id, con=con)
|
||||
new_set_id = max([set_entry.id for set_entry in curr_playlist.sets], default=0) + 1
|
||||
@@ -41,7 +41,7 @@ def add_set(session_id: int, con: Optional[Connection] = None) -> playlists.Set:
|
||||
return playlists.Set.from_playlist_entries(set_id=inserted_entry.set_id, entries=[inserted_entry])
|
||||
|
||||
|
||||
def get_set(session_id: int, set_id: int, con: Optional[Connection] = None) -> Optional[playlists.Set]:
|
||||
def get_set(session_id: int, set_id: int, con: Connection | None = None) -> playlists.Set | None:
|
||||
entries = list(query.get_playlist_entries(session_id=session_id, set_id=set_id, con=con))
|
||||
if entries:
|
||||
return playlists.Set.from_playlist_entries(set_id=set_id, entries=entries)
|
||||
@@ -49,30 +49,30 @@ def get_set(session_id: int, set_id: int, con: Optional[Connection] = None) -> O
|
||||
return None
|
||||
|
||||
|
||||
def delete_set(session_id: int, set_id: int, con: Optional[Connection] = None):
|
||||
def delete_set(session_id: int, set_id: int, con: Connection | None = None):
|
||||
write.delete_playlist_set(session_id=session_id, set_id=set_id, con=con)
|
||||
|
||||
|
||||
def add_tema(session_id: int, set_id: int, con: Optional[Connection] = None) -> playlists.TemaInSet:
|
||||
def add_tema(session_id: int, set_id: int, con: Connection | None = None) -> playlists.TemaInSet:
|
||||
with get_connection(con) as con:
|
||||
new_entry = playlists.PlaylistEntry(id=None, session_id=session_id, set_id=set_id, tema_id=None)
|
||||
inserted_entry = write.insert_playlist_entry(new_entry)
|
||||
return playlists.TemaInSet.from_playlist_entry(inserted_entry)
|
||||
|
||||
|
||||
def get_tema(entry_id: int, con: Optional[Connection] = None) -> playlists.TemaInSet:
|
||||
def get_tema(entry_id: int, con: Connection | None = None) -> playlists.TemaInSet:
|
||||
with get_connection(con) as con:
|
||||
entry = next(query.get_playlist_entries(entry_id=entry_id))
|
||||
return playlists.TemaInSet.from_playlist_entry(entry)
|
||||
|
||||
|
||||
def delete_tema(entry_id: int, con: Optional[Connection] = None):
|
||||
def delete_tema(entry_id: int, con: Connection | None = None):
|
||||
with get_connection(con) as con:
|
||||
write.delete_playlist_entry(entry_id=entry_id, con=con)
|
||||
|
||||
|
||||
def set_tema(session_id: int, set_id: int, entry_id: int, tema_id: Optional[int],
|
||||
con: Optional[Connection] = None):
|
||||
def set_tema(session_id: int, set_id: int, entry_id: int, tema_id: int | None,
|
||||
con: Connection | None = None):
|
||||
with get_connection(con) as con:
|
||||
new_entry = playlists.PlaylistEntry(id=entry_id, session_id=session_id, set_id=set_id, tema_id=tema_id)
|
||||
write.update_playlist_entry(entry=new_entry, con=con)
|
||||
|
||||
Reference in New Issue
Block a user