Clean up type hints

This commit is contained in:
Keith Edmunds 2025-01-17 21:35:29 +00:00
parent 4a4058d211
commit 5e72f17793
5 changed files with 19 additions and 19 deletions

View File

@ -2,7 +2,7 @@
import datetime as dt
import logging
import os
from typing import List, Optional
from typing import Optional
# PyQt imports
@ -35,8 +35,8 @@ class Config(object):
COLOUR_UNREADABLE = "#dc3545"
COLOUR_WARNING_TIMER = "#ffc107"
DBFS_SILENCE = -50
DEBUG_FUNCTIONS: List[Optional[str]] = []
DEBUG_MODULES: List[Optional[str]] = []
DEBUG_FUNCTIONS: list[Optional[str]] = []
DEBUG_MODULES: list[Optional[str]] = []
DEFAULT_COLUMN_WIDTH = 200
DISPLAY_SQL = False
DO_NOT_IMPORT = "Do not import"

View File

@ -1,5 +1,5 @@
# Standard library imports
from typing import List, Optional
from typing import Optional
import datetime as dt
# PyQt imports
@ -73,7 +73,7 @@ class PlaylistsTable(Model):
tab: Mapped[Optional[int]] = mapped_column(default=None)
open: 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",
back_populates="playlist",
cascade="all, delete-orphan",
@ -146,11 +146,11 @@ class TracksTable(Model):
start_gap: Mapped[int] = mapped_column(index=False)
title: Mapped[str] = mapped_column(String(256), index=True)
playlistrows: Mapped[List[PlaylistRowsTable]] = relationship(
playlistrows: Mapped[list[PlaylistRowsTable]] = relationship(
"PlaylistRowsTable", back_populates="track"
)
playlists = association_proxy("playlistrows", "playlist")
playdates: Mapped[List[PlaydatesTable]] = relationship(
playdates: Mapped[list[PlaydatesTable]] = relationship(
"PlaydatesTable",
back_populates="track",
lazy="joined",

View File

@ -1,7 +1,7 @@
# Standard library imports
from __future__ import annotations
from typing import List, Optional, Sequence
from typing import Optional, Sequence
import datetime as dt
import os
import re
@ -187,7 +187,7 @@ class Playlists(dbtables.PlaylistsTable):
session.commit()
@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
"""
@ -425,7 +425,7 @@ class PlaylistRows(dbtables.PlaylistRowsTable):
@classmethod
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"]:
"""
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(
session: Session,
playlist_id: int,
sqla_map: List[dict[str, int]],
sqla_map: list[dict[str, int]],
) -> None:
"""
Take a {plrid: row_number} dictionary and update the row numbers accordingly

View File

@ -2,7 +2,7 @@
# Standard library imports
from slugify import slugify # type: ignore
from typing import List, Optional
from typing import Optional
import argparse
import datetime as dt
import os
@ -392,7 +392,7 @@ class Window(QMainWindow, Ui_MainWindow):
self.widgetFadeVolume.setDefaultPadding(0)
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.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=}"
)
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
"""

View File

@ -1,5 +1,5 @@
# Standard library imports
from typing import Any, Callable, cast, List, Optional, TYPE_CHECKING
from typing import Any, Callable, cast, Optional, TYPE_CHECKING
# PyQt imports
from PyQt6.QtCore import (
@ -824,7 +824,7 @@ class PlaylistTab(QTableView):
else:
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"""
# 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)
def _mark_as_unplayed(self, row_numbers: List[int]) -> None:
def _mark_as_unplayed(self, row_numbers: list[int]) -> None:
"""Mark row as unplayed"""
self.get_base_model().mark_unplayed(row_numbers)
@ -1002,7 +1002,7 @@ class PlaylistTab(QTableView):
return None
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
an empty list.
@ -1031,7 +1031,7 @@ class PlaylistTab(QTableView):
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
"""