Clean up type hints
This commit is contained in:
parent
4a4058d211
commit
5e72f17793
@ -2,7 +2,7 @@
|
|||||||
import datetime as dt
|
import datetime as dt
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from typing import List, Optional
|
from typing import Optional
|
||||||
|
|
||||||
# PyQt imports
|
# PyQt imports
|
||||||
|
|
||||||
@ -35,8 +35,8 @@ class Config(object):
|
|||||||
COLOUR_UNREADABLE = "#dc3545"
|
COLOUR_UNREADABLE = "#dc3545"
|
||||||
COLOUR_WARNING_TIMER = "#ffc107"
|
COLOUR_WARNING_TIMER = "#ffc107"
|
||||||
DBFS_SILENCE = -50
|
DBFS_SILENCE = -50
|
||||||
DEBUG_FUNCTIONS: List[Optional[str]] = []
|
DEBUG_FUNCTIONS: list[Optional[str]] = []
|
||||||
DEBUG_MODULES: List[Optional[str]] = []
|
DEBUG_MODULES: list[Optional[str]] = []
|
||||||
DEFAULT_COLUMN_WIDTH = 200
|
DEFAULT_COLUMN_WIDTH = 200
|
||||||
DISPLAY_SQL = False
|
DISPLAY_SQL = False
|
||||||
DO_NOT_IMPORT = "Do not import"
|
DO_NOT_IMPORT = "Do not import"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
# Standard library imports
|
# Standard library imports
|
||||||
from typing import List, Optional
|
from typing import Optional
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
|
|
||||||
# PyQt imports
|
# PyQt imports
|
||||||
@ -73,7 +73,7 @@ class PlaylistsTable(Model):
|
|||||||
tab: Mapped[Optional[int]] = mapped_column(default=None)
|
tab: Mapped[Optional[int]] = mapped_column(default=None)
|
||||||
open: Mapped[bool] = mapped_column(default=False)
|
open: Mapped[bool] = mapped_column(default=False)
|
||||||
is_template: Mapped[bool] = mapped_column(default=False)
|
is_template: Mapped[bool] = mapped_column(default=False)
|
||||||
rows: Mapped[List["PlaylistRowsTable"]] = relationship(
|
rows: Mapped[list["PlaylistRowsTable"]] = relationship(
|
||||||
"PlaylistRowsTable",
|
"PlaylistRowsTable",
|
||||||
back_populates="playlist",
|
back_populates="playlist",
|
||||||
cascade="all, delete-orphan",
|
cascade="all, delete-orphan",
|
||||||
@ -146,11 +146,11 @@ class TracksTable(Model):
|
|||||||
start_gap: Mapped[int] = mapped_column(index=False)
|
start_gap: Mapped[int] = mapped_column(index=False)
|
||||||
title: Mapped[str] = mapped_column(String(256), index=True)
|
title: Mapped[str] = mapped_column(String(256), index=True)
|
||||||
|
|
||||||
playlistrows: Mapped[List[PlaylistRowsTable]] = relationship(
|
playlistrows: Mapped[list[PlaylistRowsTable]] = relationship(
|
||||||
"PlaylistRowsTable", back_populates="track"
|
"PlaylistRowsTable", back_populates="track"
|
||||||
)
|
)
|
||||||
playlists = association_proxy("playlistrows", "playlist")
|
playlists = association_proxy("playlistrows", "playlist")
|
||||||
playdates: Mapped[List[PlaydatesTable]] = relationship(
|
playdates: Mapped[list[PlaydatesTable]] = relationship(
|
||||||
"PlaydatesTable",
|
"PlaydatesTable",
|
||||||
back_populates="track",
|
back_populates="track",
|
||||||
lazy="joined",
|
lazy="joined",
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# Standard library imports
|
# Standard library imports
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import List, Optional, Sequence
|
from typing import Optional, Sequence
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -187,7 +187,7 @@ class Playlists(dbtables.PlaylistsTable):
|
|||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def clear_tabs(session: Session, playlist_ids: List[int]) -> None:
|
def clear_tabs(session: Session, playlist_ids: list[int]) -> None:
|
||||||
"""
|
"""
|
||||||
Make all tab records NULL
|
Make all tab records NULL
|
||||||
"""
|
"""
|
||||||
@ -425,7 +425,7 @@ class PlaylistRows(dbtables.PlaylistRowsTable):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def plrids_to_plrs(
|
def plrids_to_plrs(
|
||||||
cls, session: Session, playlist_id: int, plr_ids: List[int]
|
cls, session: Session, playlist_id: int, plr_ids: list[int]
|
||||||
) -> Sequence["PlaylistRows"]:
|
) -> Sequence["PlaylistRows"]:
|
||||||
"""
|
"""
|
||||||
Take a list of PlaylistRows ids and return a list of corresponding
|
Take a list of PlaylistRows ids and return a list of corresponding
|
||||||
@ -577,7 +577,7 @@ class PlaylistRows(dbtables.PlaylistRowsTable):
|
|||||||
def update_plr_row_numbers(
|
def update_plr_row_numbers(
|
||||||
session: Session,
|
session: Session,
|
||||||
playlist_id: int,
|
playlist_id: int,
|
||||||
sqla_map: List[dict[str, int]],
|
sqla_map: list[dict[str, int]],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Take a {plrid: row_number} dictionary and update the row numbers accordingly
|
Take a {plrid: row_number} dictionary and update the row numbers accordingly
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Standard library imports
|
# Standard library imports
|
||||||
from slugify import slugify # type: ignore
|
from slugify import slugify # type: ignore
|
||||||
from typing import List, Optional
|
from typing import Optional
|
||||||
import argparse
|
import argparse
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
import os
|
import os
|
||||||
@ -392,7 +392,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.widgetFadeVolume.setDefaultPadding(0)
|
self.widgetFadeVolume.setDefaultPadding(0)
|
||||||
self.widgetFadeVolume.setBackground(Config.FADE_CURVE_BACKGROUND)
|
self.widgetFadeVolume.setBackground(Config.FADE_CURVE_BACKGROUND)
|
||||||
|
|
||||||
self.move_source_rows: Optional[List[int]] = None
|
self.move_source_rows: Optional[list[int]] = None
|
||||||
self.move_source_model: Optional[PlaylistModel] = None
|
self.move_source_model: Optional[PlaylistModel] = None
|
||||||
|
|
||||||
self.disable_selection_timing = False
|
self.disable_selection_timing = False
|
||||||
@ -989,7 +989,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
f"mark_rows_for_moving(): {self.move_source_rows=} {self.move_source_model=}"
|
f"mark_rows_for_moving(): {self.move_source_rows=} {self.move_source_model=}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def move_playlist_rows(self, row_numbers: List[int]) -> None:
|
def move_playlist_rows(self, row_numbers: list[int]) -> None:
|
||||||
"""
|
"""
|
||||||
Move passed playlist rows to another playlist
|
Move passed playlist rows to another playlist
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
# Standard library imports
|
# Standard library imports
|
||||||
from typing import Any, Callable, cast, List, Optional, TYPE_CHECKING
|
from typing import Any, Callable, cast, Optional, TYPE_CHECKING
|
||||||
|
|
||||||
# PyQt imports
|
# PyQt imports
|
||||||
from PyQt6.QtCore import (
|
from PyQt6.QtCore import (
|
||||||
@ -824,7 +824,7 @@ class PlaylistTab(QTableView):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_selected_rows(self) -> List[int]:
|
def get_selected_rows(self) -> list[int]:
|
||||||
"""Return a list of model-selected row numbers sorted by row"""
|
"""Return a list of model-selected row numbers sorted by row"""
|
||||||
|
|
||||||
# Use a set to deduplicate result (a selected row will have all
|
# Use a set to deduplicate result (a selected row will have all
|
||||||
@ -878,7 +878,7 @@ class PlaylistTab(QTableView):
|
|||||||
|
|
||||||
show_OK(self.musicmuster, "Track info", txt)
|
show_OK(self.musicmuster, "Track info", txt)
|
||||||
|
|
||||||
def _mark_as_unplayed(self, row_numbers: List[int]) -> None:
|
def _mark_as_unplayed(self, row_numbers: list[int]) -> None:
|
||||||
"""Mark row as unplayed"""
|
"""Mark row as unplayed"""
|
||||||
|
|
||||||
self.get_base_model().mark_unplayed(row_numbers)
|
self.get_base_model().mark_unplayed(row_numbers)
|
||||||
@ -1002,7 +1002,7 @@ class PlaylistTab(QTableView):
|
|||||||
return None
|
return None
|
||||||
return self.model().mapToSource(selected_index).row()
|
return self.model().mapToSource(selected_index).row()
|
||||||
|
|
||||||
def selected_model_row_numbers(self) -> List[int]:
|
def selected_model_row_numbers(self) -> list[int]:
|
||||||
"""
|
"""
|
||||||
Return a list of model row numbers corresponding to the selected rows or
|
Return a list of model row numbers corresponding to the selected rows or
|
||||||
an empty list.
|
an empty list.
|
||||||
@ -1031,7 +1031,7 @@ class PlaylistTab(QTableView):
|
|||||||
|
|
||||||
return row_indexes[0]
|
return row_indexes[0]
|
||||||
|
|
||||||
def _selected_row_indexes(self) -> List[QModelIndex]:
|
def _selected_row_indexes(self) -> list[QModelIndex]:
|
||||||
"""
|
"""
|
||||||
Return a list of indexes of column 0 of selected rows
|
Return a list of indexes of column 0 of selected rows
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user