From 664e660198c70918c135a47a58cffc869b4fd30f Mon Sep 17 00:00:00 2001 From: KeksNino Date: Sat, 28 Feb 2026 03:31:06 +0100 Subject: [PATCH] fix a bunch of lsp errors --- src/core/interface/gui.py | 23 +++++++++++------------ src/core/network/libtorrent_misc.py | 2 +- src/core/utils/data/state.py | 8 ++++---- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/core/interface/gui.py b/src/core/interface/gui.py index 9e36a63..176dc7c 100644 --- a/src/core/interface/gui.py +++ b/src/core/interface/gui.py @@ -1,5 +1,5 @@ -from PySide6 import QtWidgets, QtCore, QtGui -from PySide6.QtCore import Qt, QTimer, QModelIndex, QAbstractTableModel, Signal, QEvent, QSize +from PySide6 import QtWidgets +from PySide6.QtCore import QPersistentModelIndex, Qt, QTimer, QModelIndex, QAbstractTableModel, Signal, QEvent, QSize from PySide6.QtWidgets import ( QLineEdit, QTableView, @@ -41,7 +41,6 @@ from core.interface.dialogs.settings import settings_dialog from core.interface.assets.base64_icons import settings_black_base64 from core.interface.assets.base64_icons import settings_white_base64 from core.interface.assets.base64_icons import logo_base64 -from core.network.libtorrent_misc import cleanup_session from core.utils.general.shutdown import closehelper @@ -183,19 +182,19 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): super().__init__() self.headers = ["Action", "Name", "Status", "Progress", "Speed", "Size", "Total Size"] - def rowCount(self, parent=QModelIndex()): + def rowCount(self, parent: QModelIndex | QPersistentModelIndex = QModelIndex()) -> int: return len(state.active_downloads) - def columnCount(self, parent=QModelIndex()): + def columnCount(self, parent: QModelIndex | QPersistentModelIndex = QModelIndex()): return len(self.headers) - def headerData(self, section, orientation, role=Qt.DisplayRole): - if role == Qt.DisplayRole and orientation == Qt.Horizontal: + def headerData(self, section, orientation, role: int = Qt.ItemDataRole.DisplayRole): + if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal: return self.headers[section] return None - def data(self, index, role=Qt.DisplayRole): - if role == Qt.DisplayRole: + def data(self, index: QModelIndex | QPersistentModelIndex, role: int = Qt.ItemDataRole.DisplayRole): + if role == Qt.ItemDataRole.DisplayRole: col = index.column() if index.row() >= len(state.active_downloads) or index.row() < 0: @@ -211,9 +210,9 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): elif col == 1: return status.name if status.has_metadata else "Fetching metadata..." elif col == 2: - if status.state == lt.torrent_status.downloading: + if status.state == lt.torrent_status.downloading: return "Downloading" - elif status.state == lt.torrent_status.seeding: + elif status.state == lt.torrent_status.seeding: return "Seeding" elif status.paused: return "Paused" @@ -257,7 +256,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): else: return "∞" if status.paused else "Stalled" - if role == Qt.UserRole and index.column() == 0: + if role == Qt.ItemDataRole.UserRole and index.column() == 0: magnet_link = list(state.active_downloads.keys())[index.row()] magnetdl = state.active_downloads[magnet_link] return magnetdl.status().paused diff --git a/src/core/network/libtorrent_misc.py b/src/core/network/libtorrent_misc.py index 64334b1..3b61fa6 100644 --- a/src/core/network/libtorrent_misc.py +++ b/src/core/network/libtorrent_misc.py @@ -57,4 +57,4 @@ def update_log(shutdown_event): updated.add(magnet_uri) except Exception: pass - time.sleep(5) \ No newline at end of file + time.sleep(5) diff --git a/src/core/utils/data/state.py b/src/core/utils/data/state.py index 717729f..0d38ce8 100644 --- a/src/core/utils/data/state.py +++ b/src/core/utils/data/state.py @@ -9,8 +9,8 @@ class AppState(QObject): def __init__(self): super().__init__() self.posts: List[Dict[str, Any]] = [] - self.post_titles: List[str] = [] - self.post_urls: List[str] = [] + self.post_titles: Optional[List] = None + self.post_urls: Optional[List] = None self.post_author: List[str] = [] self.post_seeders: List[str] = [] self.post_leechers: List[str] = [] @@ -29,11 +29,11 @@ class AppState(QObject): self.max_downloads: int = 10 self.settings_path: str = "" self.dl_session: Any = None - self.active_downloads: List[str] = {} + self.active_downloads: Dict = {} self.window_transparency: bool = False self.interfaces: List = [] self.active_interfaces: List = [] - self.bound_interface: str = None + self.bound_interface: Any = None @property def image_path(self) -> str: