Typing and mypy fixes
This commit is contained in:
parent
3513c32a62
commit
9ac2911a55
@ -19,6 +19,7 @@ from typing import (
|
|||||||
cast,
|
cast,
|
||||||
List,
|
List,
|
||||||
Optional,
|
Optional,
|
||||||
|
Sequence,
|
||||||
)
|
)
|
||||||
|
|
||||||
from PyQt6.QtCore import (
|
from PyQt6.QtCore import (
|
||||||
@ -33,6 +34,7 @@ from PyQt6.QtCore import (
|
|||||||
QTimer,
|
QTimer,
|
||||||
)
|
)
|
||||||
from PyQt6.QtGui import (
|
from PyQt6.QtGui import (
|
||||||
|
QCloseEvent,
|
||||||
QColor,
|
QColor,
|
||||||
QFont,
|
QFont,
|
||||||
QMouseEvent,
|
QMouseEvent,
|
||||||
@ -119,9 +121,12 @@ class CartButton(QPushButton):
|
|||||||
f"path={self.path}, is_playing={self.is_playing}>"
|
f"path={self.path}, is_playing={self.is_playing}>"
|
||||||
)
|
)
|
||||||
|
|
||||||
def event(self, event: QEvent) -> bool:
|
def event(self, event: Optional[QEvent]) -> bool:
|
||||||
"""Allow right click even when button is disabled"""
|
"""Allow right click even when button is disabled"""
|
||||||
|
|
||||||
|
if not event:
|
||||||
|
return False
|
||||||
|
|
||||||
if event.type() == QEvent.Type.MouseButtonRelease:
|
if event.type() == QEvent.Type.MouseButtonRelease:
|
||||||
mouse_event = cast(QMouseEvent, event)
|
mouse_event = cast(QMouseEvent, event)
|
||||||
if mouse_event.button() == Qt.MouseButton.RightButton:
|
if mouse_event.button() == Qt.MouseButton.RightButton:
|
||||||
@ -130,7 +135,7 @@ class CartButton(QPushButton):
|
|||||||
|
|
||||||
return super().event(event)
|
return super().event(event)
|
||||||
|
|
||||||
def resizeEvent(self, event: QResizeEvent) -> None:
|
def resizeEvent(self, event: Optional[QResizeEvent]) -> None:
|
||||||
"""Resize progess bar when button size changes"""
|
"""Resize progess bar when button size changes"""
|
||||||
|
|
||||||
self.pgb.setGeometry(0, 0, self.width(), 10)
|
self.pgb.setGeometry(0, 0, self.width(), 10)
|
||||||
@ -534,9 +539,12 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
# Clear the search bar
|
# Clear the search bar
|
||||||
self.search_playlist_clear()
|
self.search_playlist_clear()
|
||||||
|
|
||||||
def closeEvent(self, event: QEvent) -> None:
|
def closeEvent(self, event: Optional[QCloseEvent]) -> None:
|
||||||
"""Handle attempt to close main window"""
|
"""Handle attempt to close main window"""
|
||||||
|
|
||||||
|
if not event:
|
||||||
|
return
|
||||||
|
|
||||||
# Don't allow window to close when a track is playing
|
# Don't allow window to close when a track is playing
|
||||||
if self.playing:
|
if self.playing:
|
||||||
event.ignore()
|
event.ignore()
|
||||||
@ -1038,11 +1046,11 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
_ = self.create_playlist_tab(session, playlist)
|
_ = self.create_playlist_tab(session, playlist)
|
||||||
# Set active tab
|
# Set active tab
|
||||||
record = Settings.get_int_settings(session, "active_tab")
|
record = Settings.get_int_settings(session, "active_tab")
|
||||||
if record and record.f_int >= 0:
|
if record.f_int and record.f_int >= 0:
|
||||||
self.tabPlaylist.setCurrentIndex(record.f_int)
|
self.tabPlaylist.setCurrentIndex(record.f_int)
|
||||||
|
|
||||||
def move_playlist_rows(
|
def move_playlist_rows(
|
||||||
self, session: scoped_session, playlistrows: List[PlaylistRows]
|
self, session: scoped_session, playlistrows: Sequence[PlaylistRows]
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Move passed playlist rows to another playlist
|
Move passed playlist rows to another playlist
|
||||||
@ -1105,7 +1113,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
visible_tab.save_playlist(session)
|
visible_tab.save_playlist(session)
|
||||||
|
|
||||||
# Disable sort undo
|
# Disable sort undo
|
||||||
self.sort_undo = None
|
self.sort_undo = []
|
||||||
|
|
||||||
# Update destination playlist_tab if visible (if not visible, it
|
# Update destination playlist_tab if visible (if not visible, it
|
||||||
# will be re-populated when it is opened)
|
# will be re-populated when it is opened)
|
||||||
|
|||||||
@ -164,16 +164,19 @@ class PlaylistTab(QTableWidget):
|
|||||||
self.setVerticalScrollMode(QAbstractItemView.ScrollMode.ScrollPerPixel)
|
self.setVerticalScrollMode(QAbstractItemView.ScrollMode.ScrollPerPixel)
|
||||||
self.setRowCount(0)
|
self.setRowCount(0)
|
||||||
self.setColumnCount(len(columns))
|
self.setColumnCount(len(columns))
|
||||||
self.v_header = self.verticalHeader()
|
|
||||||
self.v_header.setMinimumSectionSize(Config.MINIMUM_ROW_HEIGHT)
|
|
||||||
self.horizontalHeader().setStretchLastSection(True)
|
|
||||||
|
|
||||||
# Header row
|
# Header row
|
||||||
|
self.h_header = self.horizontalHeader()
|
||||||
for idx in [a for a in range(len(columns))]:
|
for idx in [a for a in range(len(columns))]:
|
||||||
item = QTableWidgetItem()
|
item = QTableWidgetItem()
|
||||||
self.setHorizontalHeaderItem(idx, item)
|
self.setHorizontalHeaderItem(idx, item)
|
||||||
self.horizontalHeader().setMinimumSectionSize(0)
|
if self.h_header:
|
||||||
|
self.h_header.setStretchLastSection(True)
|
||||||
|
self.h_header.setMinimumSectionSize(0)
|
||||||
# Set column headings sorted by idx
|
# Set column headings sorted by idx
|
||||||
|
self.v_header = self.verticalHeader()
|
||||||
|
if self.v_header:
|
||||||
|
self.v_header.setMinimumSectionSize(Config.MINIMUM_ROW_HEIGHT)
|
||||||
self.setHorizontalHeaderLabels(
|
self.setHorizontalHeaderLabels(
|
||||||
[
|
[
|
||||||
a.heading
|
a.heading
|
||||||
@ -215,13 +218,16 @@ class PlaylistTab(QTableWidget):
|
|||||||
|
|
||||||
# ########## Events other than cell editing ##########
|
# ########## Events other than cell editing ##########
|
||||||
|
|
||||||
def dropEvent(self, event: QDropEvent) -> None:
|
def dropEvent(self, event: Optional[QDropEvent]) -> None:
|
||||||
"""
|
"""
|
||||||
Handle drag/drop of rows
|
Handle drag/drop of rows
|
||||||
|
|
||||||
https://stackoverflow.com/questions/26227885/drag-and-drop-rows-within-qtablewidget
|
https://stackoverflow.com/questions/26227885/drag-and-drop-rows-within-qtablewidget
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if not event:
|
||||||
|
return
|
||||||
|
|
||||||
if not event.source() == self:
|
if not event.source() == self:
|
||||||
return # We don't accept external drops
|
return # We don't accept external drops
|
||||||
|
|
||||||
@ -267,7 +273,7 @@ class PlaylistTab(QTableWidget):
|
|||||||
# Reset drag mode to allow row selection by dragging
|
# Reset drag mode to allow row selection by dragging
|
||||||
self.setDragEnabled(False)
|
self.setDragEnabled(False)
|
||||||
# Disable sort undo
|
# Disable sort undo
|
||||||
self.sort_undo = None
|
self.sort_undo = []
|
||||||
|
|
||||||
with Session() as session:
|
with Session() as session:
|
||||||
self.save_playlist(session)
|
self.save_playlist(session)
|
||||||
@ -1103,7 +1109,7 @@ class PlaylistTab(QTableWidget):
|
|||||||
)
|
)
|
||||||
if sort_menu:
|
if sort_menu:
|
||||||
sort_menu.setEnabled(self._sortable())
|
sort_menu.setEnabled(self._sortable())
|
||||||
self._add_context_menu("Undo sort", self._sort_undo, self.sort_undo is None)
|
self._add_context_menu("Undo sort", self._sort_undo, not bool(self.sort_undo))
|
||||||
|
|
||||||
# Build submenu
|
# Build submenu
|
||||||
|
|
||||||
@ -2123,9 +2129,7 @@ class PlaylistTab(QTableWidget):
|
|||||||
stackprinter.format(),
|
stackprinter.format(),
|
||||||
)
|
)
|
||||||
# stackprinter.show(add_summary=True, style="darkbg")
|
# stackprinter.show(add_summary=True, style="darkbg")
|
||||||
print(
|
print(f"playists:_set_row_note_colour() called on track row ({row_number=}")
|
||||||
f"playists:_set_row_note_colour() called on track row ({row_number=}"
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Set colour
|
# Set colour
|
||||||
|
|||||||
@ -1,14 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Form implementation generated from reading ui file 'dlg_Cart.ui'
|
||||||
|
|
||||||
# Form implementation generated from reading ui file 'app/ui/dlg_Cart.ui'
|
|
||||||
#
|
#
|
||||||
# Created by: PyQt5 UI code generator 5.15.6
|
# Created by: PyQt6 UI code generator 6.5.3
|
||||||
#
|
#
|
||||||
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
|
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
|
||||||
# run again. Do not edit this file unless you know what you are doing.
|
# run again. Do not edit this file unless you know what you are doing.
|
||||||
|
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
|
|
||||||
class Ui_DialogCartEdit(object):
|
class Ui_DialogCartEdit(object):
|
||||||
@ -17,43 +15,43 @@ class Ui_DialogCartEdit(object):
|
|||||||
DialogCartEdit.resize(564, 148)
|
DialogCartEdit.resize(564, 148)
|
||||||
self.gridLayout = QtWidgets.QGridLayout(DialogCartEdit)
|
self.gridLayout = QtWidgets.QGridLayout(DialogCartEdit)
|
||||||
self.gridLayout.setObjectName("gridLayout")
|
self.gridLayout.setObjectName("gridLayout")
|
||||||
self.label = QtWidgets.QLabel(DialogCartEdit)
|
self.label = QtWidgets.QLabel(parent=DialogCartEdit)
|
||||||
self.label.setMaximumSize(QtCore.QSize(56, 16777215))
|
self.label.setMaximumSize(QtCore.QSize(56, 16777215))
|
||||||
self.label.setObjectName("label")
|
self.label.setObjectName("label")
|
||||||
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
|
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
|
||||||
self.lineEditName = QtWidgets.QLineEdit(DialogCartEdit)
|
self.lineEditName = QtWidgets.QLineEdit(parent=DialogCartEdit)
|
||||||
self.lineEditName.setInputMask("")
|
self.lineEditName.setInputMask("")
|
||||||
self.lineEditName.setObjectName("lineEditName")
|
self.lineEditName.setObjectName("lineEditName")
|
||||||
self.gridLayout.addWidget(self.lineEditName, 0, 1, 1, 2)
|
self.gridLayout.addWidget(self.lineEditName, 0, 1, 1, 2)
|
||||||
self.chkEnabled = QtWidgets.QCheckBox(DialogCartEdit)
|
self.chkEnabled = QtWidgets.QCheckBox(parent=DialogCartEdit)
|
||||||
self.chkEnabled.setObjectName("chkEnabled")
|
self.chkEnabled.setObjectName("chkEnabled")
|
||||||
self.gridLayout.addWidget(self.chkEnabled, 0, 3, 1, 1)
|
self.gridLayout.addWidget(self.chkEnabled, 0, 3, 1, 1)
|
||||||
self.label_2 = QtWidgets.QLabel(DialogCartEdit)
|
self.label_2 = QtWidgets.QLabel(parent=DialogCartEdit)
|
||||||
self.label_2.setMaximumSize(QtCore.QSize(56, 16777215))
|
self.label_2.setMaximumSize(QtCore.QSize(56, 16777215))
|
||||||
self.label_2.setObjectName("label_2")
|
self.label_2.setObjectName("label_2")
|
||||||
self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
|
self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
|
||||||
self.lblPath = QtWidgets.QLabel(DialogCartEdit)
|
self.lblPath = QtWidgets.QLabel(parent=DialogCartEdit)
|
||||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
|
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred)
|
||||||
sizePolicy.setHorizontalStretch(0)
|
sizePolicy.setHorizontalStretch(0)
|
||||||
sizePolicy.setVerticalStretch(0)
|
sizePolicy.setVerticalStretch(0)
|
||||||
sizePolicy.setHeightForWidth(self.lblPath.sizePolicy().hasHeightForWidth())
|
sizePolicy.setHeightForWidth(self.lblPath.sizePolicy().hasHeightForWidth())
|
||||||
self.lblPath.setSizePolicy(sizePolicy)
|
self.lblPath.setSizePolicy(sizePolicy)
|
||||||
self.lblPath.setMinimumSize(QtCore.QSize(301, 41))
|
self.lblPath.setMinimumSize(QtCore.QSize(301, 41))
|
||||||
self.lblPath.setText("")
|
self.lblPath.setText("")
|
||||||
self.lblPath.setTextFormat(QtCore.Qt.PlainText)
|
self.lblPath.setTextFormat(QtCore.Qt.TextFormat.PlainText)
|
||||||
self.lblPath.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
|
self.lblPath.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignTop)
|
||||||
self.lblPath.setWordWrap(True)
|
self.lblPath.setWordWrap(True)
|
||||||
self.lblPath.setObjectName("lblPath")
|
self.lblPath.setObjectName("lblPath")
|
||||||
self.gridLayout.addWidget(self.lblPath, 1, 1, 1, 1)
|
self.gridLayout.addWidget(self.lblPath, 1, 1, 1, 1)
|
||||||
self.btnFile = QtWidgets.QPushButton(DialogCartEdit)
|
self.btnFile = QtWidgets.QPushButton(parent=DialogCartEdit)
|
||||||
self.btnFile.setMaximumSize(QtCore.QSize(31, 16777215))
|
self.btnFile.setMaximumSize(QtCore.QSize(31, 16777215))
|
||||||
self.btnFile.setObjectName("btnFile")
|
self.btnFile.setObjectName("btnFile")
|
||||||
self.gridLayout.addWidget(self.btnFile, 1, 3, 1, 1)
|
self.gridLayout.addWidget(self.btnFile, 1, 3, 1, 1)
|
||||||
spacerItem = QtWidgets.QSpacerItem(116, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
spacerItem = QtWidgets.QSpacerItem(116, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||||
self.gridLayout.addItem(spacerItem, 2, 1, 1, 1)
|
self.gridLayout.addItem(spacerItem, 2, 1, 1, 1)
|
||||||
self.buttonBox = QtWidgets.QDialogButtonBox(DialogCartEdit)
|
self.buttonBox = QtWidgets.QDialogButtonBox(parent=DialogCartEdit)
|
||||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
|
||||||
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
|
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
|
||||||
self.buttonBox.setObjectName("buttonBox")
|
self.buttonBox.setObjectName("buttonBox")
|
||||||
self.gridLayout.addWidget(self.buttonBox, 2, 2, 1, 2)
|
self.gridLayout.addWidget(self.buttonBox, 2, 2, 1, 2)
|
||||||
self.label.setBuddy(self.lineEditName)
|
self.label.setBuddy(self.lineEditName)
|
||||||
|
|||||||
@ -1,10 +1,34 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Form implementation generated from reading ui file 'dlg_SelectPlaylist.ui'
|
||||||
|
|
||||||
# Form implementation generated from reading ui file 'ui/playlist.ui'
|
|
||||||
#
|
#
|
||||||
# Created by: PyQt5 UI code generator 5.15.4
|
# Created by: PyQt6 UI code generator 6.5.3
|
||||||
#
|
#
|
||||||
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
|
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
|
||||||
# run again. Do not edit this file unless you know what you are doing.
|
# run again. Do not edit this file unless you know what you are doing.
|
||||||
|
|
||||||
|
|
||||||
|
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
|
|
||||||
|
class Ui_dlgSelectPlaylist(object):
|
||||||
|
def setupUi(self, dlgSelectPlaylist):
|
||||||
|
dlgSelectPlaylist.setObjectName("dlgSelectPlaylist")
|
||||||
|
dlgSelectPlaylist.resize(276, 150)
|
||||||
|
self.verticalLayout = QtWidgets.QVBoxLayout(dlgSelectPlaylist)
|
||||||
|
self.verticalLayout.setObjectName("verticalLayout")
|
||||||
|
self.lstPlaylists = QtWidgets.QListWidget(parent=dlgSelectPlaylist)
|
||||||
|
self.lstPlaylists.setObjectName("lstPlaylists")
|
||||||
|
self.verticalLayout.addWidget(self.lstPlaylists)
|
||||||
|
self.buttonBox = QtWidgets.QDialogButtonBox(parent=dlgSelectPlaylist)
|
||||||
|
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
|
||||||
|
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
|
||||||
|
self.buttonBox.setObjectName("buttonBox")
|
||||||
|
self.verticalLayout.addWidget(self.buttonBox)
|
||||||
|
|
||||||
|
self.retranslateUi(dlgSelectPlaylist)
|
||||||
|
self.buttonBox.accepted.connect(dlgSelectPlaylist.accept) # type: ignore
|
||||||
|
self.buttonBox.rejected.connect(dlgSelectPlaylist.reject) # type: ignore
|
||||||
|
QtCore.QMetaObject.connectSlotsByName(dlgSelectPlaylist)
|
||||||
|
|
||||||
|
def retranslateUi(self, dlgSelectPlaylist):
|
||||||
|
_translate = QtCore.QCoreApplication.translate
|
||||||
|
dlgSelectPlaylist.setWindowTitle(_translate("dlgSelectPlaylist", "Dialog"))
|
||||||
|
|||||||
1102
poetry.lock
generated
1102
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@ -13,7 +13,6 @@ mysqlclient = "^2.1.0"
|
|||||||
mutagen = "^1.45.1"
|
mutagen = "^1.45.1"
|
||||||
alembic = "^1.7.5"
|
alembic = "^1.7.5"
|
||||||
psutil = "^5.9.0"
|
psutil = "^5.9.0"
|
||||||
PyQtWebEngine = "^5.15.5"
|
|
||||||
pydub = "^0.25.1"
|
pydub = "^0.25.1"
|
||||||
types-psutil = "^5.8.22"
|
types-psutil = "^5.8.22"
|
||||||
python-slugify = "^6.1.2"
|
python-slugify = "^6.1.2"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user