pylance standardization
This commit is contained in:
+5
-4
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Filename: about.py
|
||||
Description: About window for FLARES
|
||||
Description: About window
|
||||
Note: Compliant with pylance strict type checking
|
||||
|
||||
Author: Tyler de Zeeuw
|
||||
License: GPL-3.0
|
||||
@@ -9,7 +10,7 @@ License: GPL-3.0
|
||||
from PySide6.QtWidgets import QWidget, QVBoxLayout, QLabel
|
||||
from PySide6.QtCore import Qt
|
||||
|
||||
from src.shared.shareddata import APP_NAME, CURRENT_VERSION
|
||||
from src.shared.shareddata import APP_NAME, APP_NAME_EXPANDED, CURRENT_VERSION
|
||||
|
||||
class AboutWindow(QWidget):
|
||||
"""
|
||||
@@ -19,14 +20,14 @@ class AboutWindow(QWidget):
|
||||
parent (QWidget, optional): Parent widget of this window. Defaults to None.
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent, Qt.WindowType.Window)
|
||||
self.setWindowTitle(f"About {APP_NAME.upper()}")
|
||||
self.resize(250, 100)
|
||||
|
||||
layout = QVBoxLayout()
|
||||
label = QLabel(f"About {APP_NAME.upper()}", self)
|
||||
label2 = QLabel("fNIRS Lightweight Analysis, Research, & Evaluation Suite", self)
|
||||
label2 = QLabel(f"{APP_NAME_EXPANDED}", self)
|
||||
label3 = QLabel(f"{APP_NAME.upper()} is licensed under the GPL-3.0 licence. For more information, visit https://www.gnu.org/licenses/gpl-3.0.en.html", self)
|
||||
label4 = QLabel(f"Version v{CURRENT_VERSION}")
|
||||
|
||||
|
||||
+13
-10
@@ -1,21 +1,24 @@
|
||||
"""
|
||||
Filename: terminal.py
|
||||
Description: Terminal window for FLARES
|
||||
Description: Terminal window
|
||||
Note: Compliant with pylance strict type checking
|
||||
|
||||
Author: Tyler de Zeeuw
|
||||
License: GPL-3.0
|
||||
"""
|
||||
|
||||
from typing import Any, Callable
|
||||
|
||||
from PySide6.QtWidgets import QWidget, QVBoxLayout, QTextEdit, QLineEdit
|
||||
from PySide6.QtCore import Qt
|
||||
|
||||
from src.shared.shareddata import API_URL, API_URL_SECONDARY, APP_NAME, CURRENT_VERSION, PLATFORM_NAME
|
||||
from src.window.about import AboutWindow
|
||||
from updater import LocalPendingUpdateCheckThread, UpdateManager
|
||||
from updater import UpdateManager
|
||||
|
||||
|
||||
class TerminalWindow(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent, Qt.WindowType.Window)
|
||||
self.setWindowTitle(f"Terminal - {APP_NAME.upper()}")
|
||||
self.resize(320, 180)
|
||||
@@ -30,7 +33,7 @@ class TerminalWindow(QWidget):
|
||||
layout.addWidget(self.input_line)
|
||||
self.setLayout(layout)
|
||||
|
||||
self.commands = {
|
||||
self.commands: dict[str, Callable[..., Any]] = {
|
||||
"hello": self.cmd_hello,
|
||||
"help": self.cmd_help,
|
||||
"version": self.cmd_version,
|
||||
@@ -68,22 +71,22 @@ class TerminalWindow(QWidget):
|
||||
self.output_area.append(f"[Unknown command] '{command_name}'")
|
||||
|
||||
|
||||
def cmd_hello(self, *args):
|
||||
def cmd_hello(self, *args: Any) -> str:
|
||||
return "Hello from the terminal!"
|
||||
|
||||
def cmd_help(self, *args):
|
||||
def cmd_help(self, *args: Any) -> str:
|
||||
return f"Available commands: {', '.join(self.commands.keys())}"
|
||||
|
||||
def cmd_version(self, *args):
|
||||
def cmd_version(self, *args: Any) -> str:
|
||||
return f"{APP_NAME.upper()} is running version {CURRENT_VERSION}."
|
||||
|
||||
def cmd_about(self, *args):
|
||||
def cmd_about(self, *args: Any) -> None:
|
||||
self.about = AboutWindow(self)
|
||||
self.about.show()
|
||||
|
||||
def cmd_update(self, *args):
|
||||
def cmd_update(self, *args: Any) -> str:
|
||||
main_win = self.parent()
|
||||
if main_win is None:
|
||||
if not isinstance(main_win, QWidget):
|
||||
return "[Error] Main window context not found."
|
||||
|
||||
self.updater = UpdateManager(
|
||||
|
||||
@@ -15,9 +15,9 @@ import numpy as np
|
||||
from PySide6.QtWidgets import QWidget, QVBoxLayout, QLabel, QHBoxLayout, QMessageBox, QLineEdit, QPushButton, QFileDialog
|
||||
from PySide6.QtCore import Qt
|
||||
|
||||
from mne.io import read_raw_snirf
|
||||
from mne_nirs.io import write_raw_snirf
|
||||
from mne.channels import make_dig_montage
|
||||
from mne.io import read_raw_snirf #type: ignore
|
||||
from mne_nirs.io import write_raw_snirf #type: ignore
|
||||
from mne.channels import make_dig_montage #type: ignore
|
||||
|
||||
from src.shared.shareddata import APP_NAME
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class UserGuideWindow(QWidget):
|
||||
parent (QWidget, optional): Parent widget of this window. Defaults to None.
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, parent: QWidget | None = None) -> None:
|
||||
super().__init__(parent, Qt.WindowType.Window)
|
||||
self.setWindowTitle(f"User Guide - {APP_NAME.upper()}")
|
||||
self.resize(250, 100)
|
||||
|
||||
@@ -40,7 +40,7 @@ class ViewerLauncherWidget(QWidget):
|
||||
("Cross-Group Stats Viewer", CrossGroupStatsWidget, [haemo_dict, cha_dict, df_ind_dict, design_matrix_dict, contrast_results_dict, group_dict, json_location], True),
|
||||
("Inter-Group Brain and Image Viewer", InterGroupBrainImageWidget, [haemo_dict, cha_dict, df_ind_dict, design_matrix_dict, contrast_results_dict, group_dict], True),
|
||||
("Cross-Group Brain and Image Viewer", CrossGroupBrainImageWidget, [haemo_dict, df_ind_dict, design_matrix_dict, contrast_results_dict, group_dict], True),
|
||||
("Export To CSV Viewer", ExportToCSVWidget, [haemo_dict, cha_dict, df_ind_dict, design_matrix_dict, group_dict, contrast_results_dict], True)
|
||||
("Export To CSV Viewer", ExportToCSVWidget, [haemo_dict, cha_dict, df_ind_dict, design_matrix_dict, contrast_results_dict, group_dict], True)
|
||||
]
|
||||
|
||||
layout = QVBoxLayout(self)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Filename: welcome.py
|
||||
Description: Welcome dialog for FLARES
|
||||
Note: Compliant with pylance strict type checking
|
||||
|
||||
Author: Tyler de Zeeuw
|
||||
License: GPL-3.0
|
||||
@@ -9,13 +10,13 @@ License: GPL-3.0
|
||||
from PySide6.QtWidgets import QTextBrowser, QVBoxLayout, QLabel, QDialog, QHBoxLayout, QPushButton
|
||||
from PySide6.QtGui import QDesktopServices, QIcon
|
||||
from PySide6.QtCore import QUrl
|
||||
from PySide6.QtNetwork import QNetworkAccessManager, QNetworkRequest
|
||||
from PySide6.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply
|
||||
|
||||
from src.shared.shareddata import APP_NAME, CURRENT_VERSION, CHANGELOG_URL, resource_path
|
||||
|
||||
|
||||
class WelcomeDialog(QDialog):
|
||||
def __init__(self, parent=None, direct=True, first=False):
|
||||
def __init__(self, parent: QDialog | None = None, direct: bool = True, first: bool = False):
|
||||
super().__init__(parent)
|
||||
self.setWindowTitle(f"What's New - {APP_NAME.upper()}")
|
||||
self.setMinimumSize(550, 450)
|
||||
@@ -64,10 +65,10 @@ class WelcomeDialog(QDialog):
|
||||
self.network_manager.get(QNetworkRequest(QUrl(CHANGELOG_URL)))
|
||||
|
||||
|
||||
def _on_download_complete(self, reply):
|
||||
def _on_download_complete(self, reply: QNetworkReply) -> None:
|
||||
"""Processes the downloaded markdown and drops it into the view frame."""
|
||||
if reply.error() == reply.NetworkError.NoError:
|
||||
raw_bytes = reply.readAll()
|
||||
raw_bytes = reply.readAll().data()
|
||||
|
||||
# Convert raw bytes to standard text string
|
||||
markdown_text = str(raw_bytes, encoding='utf-8')
|
||||
|
||||
Reference in New Issue
Block a user