From 365a96cc4bf8eef4c6f93bc94a1a5f0aa17b921d Mon Sep 17 00:00:00 2001 From: "amaork@Home_WIN7" Date: Fri, 18 Mar 2022 18:36:15 +0800 Subject: [PATCH] remove "# noinspection PyTypeChecker" --- dashboard/input.py | 11 ----- demos/checkbox_demo.py | 1 - demos/dashboard_input_test.py | 6 +-- demos/dialog_demo.py | 2 - demos/event_filter_test.py | 3 +- demos/monitor_demo.py | 3 +- demos/status_demo.py | 4 +- demos/tabbar_demo.py | 5 ++- demos/tarmanager_test.py | 16 +++---- demos/widget_demo.py | 9 +--- gui/binder.py | 1 - gui/button.py | 2 - gui/container.py | 12 +---- gui/dialog.py | 30 ------------- gui/mailbox.py | 3 -- gui/misc.py | 9 ---- gui/msgbox.py | 1 - gui/srm.py | 18 -------- gui/view.py | 10 ----- gui/widget.py | 83 ----------------------------------- 20 files changed, 24 insertions(+), 205 deletions(-) diff --git a/dashboard/input.py b/dashboard/input.py index d46444d..ca5dc15 100644 --- a/dashboard/input.py +++ b/dashboard/input.py @@ -116,7 +116,6 @@ def paintEvent(self, ev: QPaintEvent): fm = QFontMetrics(font) painter.setPen(self.bg_color) painter.setFont(font) - # noinspection PyTypeChecker painter.drawText(self.MARGIN + self.outer_ring_diameter / 2 - fm.width(self.state) / 2, self.MARGIN + self.outer_ring_diameter / 2 + fm.height() / 3, self.tr(self.state)) @@ -252,7 +251,6 @@ class VirtualNumberInput(QLineEdit): __textColor = QColor(255, 255, 255) __hoverColor = QColor(0x96, 0xf7, 0x51) - # noinspection PyTypeChecker def __init__(self, initial_value: Union[int, float] = 0, min_: Union[int, float] = 0, max_: Union[int, float] = 9999, decimals: int = 0, parent: Optional[QWidget] = None): @@ -311,11 +309,8 @@ def hoverStylesheet(cls): UiColorInput.get_bg_color_stylesheet(cls.color2Tuple(cls.getThemeColor())) def showKeyboard(self): - # noinspection PyTypeChecker input_min = self.property("min") - # noinspection PyTypeChecker input_max = self.property("max") - # noinspection PyTypeChecker input_decimals = self.property("decimals") if not input_decimals: value = VirtualNumberKeyboard.getInt(min_=input_min, max_=input_max, parent=self) @@ -327,7 +322,6 @@ def showKeyboard(self): self.numberChanged.emit(value) def setValue(self, value: Union[int, float]): - # noinspection PyTypeChecker number_decimals = self.property('decimals') self.setText("{0:.{1}f}".format(value, number_decimals) if number_decimals else str(value)) @@ -419,16 +413,13 @@ def __initUi(self): key_layout = QGridLayout() for row, row_keys in enumerate(self.key_map): for column, key in enumerate(row_keys): - # noinspection PyTypeChecker key = { self.OK_KEY: self.tr("OK"), self.CANCEL_KEY: self.tr("Cancel") }.get(key, key) btn = QPushButton(key) btn.clicked.connect(self.slotNumberClicked) - # noinspection PyTypeChecker btn.setProperty("name", key) - # noinspection PyTypeChecker btn.setProperty("value", key) btn.setMinimumHeight(50 * self.__scale_factor) btn.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) @@ -467,9 +458,7 @@ def __initStyle(self): self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint) def __initSignalAndSlots(self): - # noinspection PyTypeChecker ok = self.ui_manager.getByValue("name", self.tr(self.OK_KEY), QPushButton) - # noinspection PyTypeChecker cancel = self.ui_manager.getByValue("name", self.tr(self.CANCEL_KEY), QPushButton) ok.clicked.connect(self.accept) cancel.clicked.connect(self.reject) diff --git a/demos/checkbox_demo.py b/demos/checkbox_demo.py index 2809725..ca16bc3 100644 --- a/demos/checkbox_demo.py +++ b/demos/checkbox_demo.py @@ -15,7 +15,6 @@ class CheckboxDemoWidget(BasicWidget): def __init__(self, parent=None): super(CheckboxDemoWidget, self).__init__(parent) - # noinspection PyTypeChecker def _initUi(self): self.def_style = CheckBoxStyleSheet.default() style = DynamicObject(background=(240, 240, 240), font=("宋体", 9)) diff --git a/demos/dashboard_input_test.py b/demos/dashboard_input_test.py index ca3a83d..97cfd3d 100644 --- a/demos/dashboard_input_test.py +++ b/demos/dashboard_input_test.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- import sys import math -from PySide2.QtWidgets import * +from PySide2.QtWidgets import QPushButton, QLabel, QSpinBox, QColorDialog, QApplication, QSizePolicy, \ + QAbstractSpinBox, QGridLayout, QDoubleSpinBox + from ..gui.widget import BasicWidget from ..gui.container import ComponentManager from ..dashboard.input import VirtualNumberInput @@ -47,7 +49,6 @@ def _initUi(self): self.setLayout(layout) self.ui_manager = ComponentManager(layout) - # noinspection PyTypeChecker self.setWindowTitle(self.tr("Dashboard 虚拟键盘输入测试")) def _initData(self): @@ -78,7 +79,6 @@ def _initSignalAndSlots(self): self.ui_theme_color.clicked.connect(self.slotChangeKeyboardThemeColor) self.ui_hover_color.clicked.connect(self.slotChangeKeyboardHoverColor) - # noinspection PyTypeChecker def slotInputRangeChanged(self, value): if self.sender() == self.ui_int_min: self.ui_int_input.setProperty("min", value) diff --git a/demos/dialog_demo.py b/demos/dialog_demo.py index b5fcabc..2860c15 100644 --- a/demos/dialog_demo.py +++ b/demos/dialog_demo.py @@ -15,7 +15,6 @@ def __init__(self, parent=None): self.__initSignalAndSlots() self.__uiManager = ComponentManager(self.layout()) - # noinspection PyTypeChecker def __initUi(self): diff = QHBoxLayout() self.__diff = QPushButton(self.tr("获取颜色(RGB 不同)")) @@ -33,7 +32,6 @@ def __initUi(self): same = QHBoxLayout() self.__sameColor = QLabel() self.__sameColor.setMinimumSize(32, 15) - # noinspection PyTypeChecker self.__same = QPushButton(self.tr("获取颜色(RGB 相同)")) color = QSpinBox() color.setRange(0, 7) diff --git a/demos/event_filter_test.py b/demos/event_filter_test.py index cda8ccc..6d96a52 100644 --- a/demos/event_filter_test.py +++ b/demos/event_filter_test.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- import sys -from PySide2.QtWidgets import * from PySide2.QtCore import QEvent +from PySide2.QtWidgets import QPushButton, QRadioButton, QCheckBox, QLineEdit, QDoubleSpinBox, QSpinBox, QLabel, \ + QHBoxLayout, QApplication from ..gui.msgbox import * from ..gui.widget import BasicWidget diff --git a/demos/monitor_demo.py b/demos/monitor_demo.py index ef89938..c87d63b 100644 --- a/demos/monitor_demo.py +++ b/demos/monitor_demo.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- import sys import random -from PySide2.QtWidgets import * +from PySide2.QtWidgets import QApplication, QHBoxLayout + from ..dashboard.monitor import * from ..gui.widget import BasicWidget from ..gui.container import ComponentManager diff --git a/demos/status_demo.py b/demos/status_demo.py index 45c9871..55d3767 100644 --- a/demos/status_demo.py +++ b/demos/status_demo.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- import sys import random -from PySide2.QtWidgets import * from PySide2.QtGui import QColor +from PySide2.QtWidgets import QPushButton, QHBoxLayout, QGridLayout, QApplication, QColorDialog + from ..gui.widget import BasicWidget from ..gui.container import ComponentManager from ..dashboard.status import DashboardStatusIcon @@ -12,7 +13,6 @@ class DemoDashboardStatus(BasicWidget): def __init__(self, parent=None): super(DemoDashboardStatus, self).__init__(parent) - # noinspection PyTypeChecker def _initUi(self): layout = QHBoxLayout() diff --git a/demos/tabbar_demo.py b/demos/tabbar_demo.py index 30f061c..53a04ef 100644 --- a/demos/tabbar_demo.py +++ b/demos/tabbar_demo.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- import sys -from PySide2.QtWidgets import * +from PySide2.QtWidgets import QApplication, QWidget, QTabWidget, QHBoxLayout, QRadioButton, QLabel, QComboBox, \ + QButtonGroup + from ..gui.misc import TabBar from ..gui.container import ComponentManager @@ -9,7 +11,6 @@ class TabBarDemo(QWidget): PositionText = ["East", "West", "South", "North"] Positions = [QTabWidget.East, QTabWidget.West, QTabWidget.South, QTabWidget.North] - # noinspection PyTypeChecker def __init__(self, parent=None): super(TabBarDemo, self).__init__(parent) diff --git a/demos/tarmanager_test.py b/demos/tarmanager_test.py index 624b314..37971d2 100644 --- a/demos/tarmanager_test.py +++ b/demos/tarmanager_test.py @@ -6,14 +6,14 @@ def usage(): - print("\n{} -c[x] -s xxx -d xxx -f xxx\n".format(os.path.basename(sys.argv[0]))) - print("\t-h\--help\tshow this help menu") - print("\t-v\--verbose\toutput verbose message") - print("\t-c\--create\tcreate a package file") - print("\t-x\--extract\textract a package file") - print("\t-s\--src\tspecify will package file path or will extract file path") - print("\t-d\--dest\tspecify package file name or will extract file path") - print("\t-x\--format\tspecify package file format: {}".format(TarManager.get_support_format())) + print(r"\n{} -c[x] -s xxx -d xxx -f xxx\n".format(os.path.basename(sys.argv[0]))) + print(r"\t-h--help show this help menu") + print(r"\t-v--verbose output verbose message") + print(r"\t-c--create create a package file") + print(r"\t-x--extract extract a package file") + print(r"\t-s--src specify will package file path or will extract file path") + print(r"\t-d--dest specify package file name or will extract file path") + print(r"\t-x--format specify package file format: {}".format(TarManager.get_support_format())) if __name__ == '__main__': diff --git a/demos/widget_demo.py b/demos/widget_demo.py index 9886723..47b2047 100644 --- a/demos/widget_demo.py +++ b/demos/widget_demo.py @@ -2,9 +2,10 @@ import os import sys import datetime -from PySide2.QtWidgets import * from PySide2.QtCore import Qt, QDir, Signal from PySide2.QtGui import QColor, QImageReader +from PySide2.QtWidgets import QApplication, QPushButton, QMainWindow, QWidget, QTextEdit, QFontDialog, QLabel, \ + QLineEdit, QVBoxLayout, QHBoxLayout, QGridLayout, QInputDialog, QProgressBar, QFrame from ..gui.widget import * from ..misc.settings import * @@ -13,7 +14,6 @@ from ..gui.dialog import showFileImportDialog from ..gui.widget import SerialPortSettingWidget from ..gui.misc import NavigationItem, NavigationBar -from ..misc.crypto import RSAPrivateKeyHandle from ..gui.srm import SoftwareRegistrationMachineWidget @@ -369,7 +369,6 @@ def __init__(self, parent=None): super(SerialSettingWidgetTest, self).__init__(parent) self.__text = QTextEdit() self.__setting = SerialPortSettingWidget() - # noinspection PyTypeChecker get_setting = QPushButton(self.tr("获取串口设置")) get_setting.clicked.connect(self.slotGetSetting) @@ -379,7 +378,6 @@ def __init__(self, parent=None): layout.addWidget(self.__text) self.setLayout(layout) - # noinspection PyTypeChecker self.setWindowTitle(self.tr("串口设置对话框")) def slotGetSetting(self): @@ -393,7 +391,6 @@ def __init__(self, parent=None): layout = QVBoxLayout() self.widget = JsonSettingWidget(UiInputSetting.getDemoSettings()) self.widget.settingChanged.connect(self.slotShowData) - # noinspection PyTypeChecker self.ui_button = QPushButton(self.tr("Get settings")) self.ui_button.clicked.connect(self.slotShowData) self.ui_data = QTextEdit() @@ -444,10 +441,8 @@ def __init__(self, parent=None): self.widget = MultiJsonSettingsWidget(MultiJsonSetting.default(), data) self.widget.settingChanged.connect(self.slotShowData) - # noinspection PyTypeChecker self.ui_get = QPushButton(self.tr("Get settings")) self.ui_get.clicked.connect(self.slotShowData) - # noinspection PyTypeChecker self.ui_reset = QPushButton(self.tr("Reset data")) self.ui_reset.clicked.connect(self.slotResetData) self.ui_data = QTextEdit() diff --git a/gui/binder.py b/gui/binder.py index 6c4c58d..5a219fc 100644 --- a/gui/binder.py +++ b/gui/binder.py @@ -78,7 +78,6 @@ def eventProcess(self, value: Union[int, float]): receiver.setValue(self.__remap(factor, value)) # QLabel or QLineEdit elif isinstance(receiver, (QLabel, QLineEdit)): - # noinspection PyTypeChecker fmt = receiver.property('format') fmt = fmt if isinstance(fmt, str) else "{}" receiver.setText(fmt.format(self.__remap(factor, value))) diff --git a/gui/button.py b/gui/button.py index 1c3e32c..abac7f9 100644 --- a/gui/button.py +++ b/gui/button.py @@ -23,7 +23,6 @@ def __init__(self, width: int = 0, height: int = 0, shortCut: str = "", styleSheet: str = "", tips: str = "", parent: Optional[QWidget] = None): super(BaseButton, self).__init__(parent) if isinstance(shortCut, str) and len(shortCut): - # noinspection PyTypeChecker self.setShortcut(QKeySequence(self.tr(shortCut))) if isinstance(styleSheet, str) and len(styleSheet): @@ -58,7 +57,6 @@ def __init__(self, width: int = 0, height: int = 0, text: Tuple[str, str] = ("", self.text = ("", "") if isinstance(text, (tuple, list)) and len(text) == 2: self.text = text - # noinspection PyTypeChecker self.setText(self.tr(text[0])) def slotChangeView(self, ck: bool): diff --git a/gui/container.py b/gui/container.py index 7734e3a..c57506b 100644 --- a/gui/container.py +++ b/gui/container.py @@ -4,7 +4,8 @@ """ from PySide2.QtCore import * -from PySide2.QtWidgets import * +from PySide2.QtWidgets import QComboBox, QWidget, QDoubleSpinBox, QSpinBox, QLineEdit, QPlainTextEdit, QDateTimeEdit, \ + QDial, QRadioButton, QCheckBox, QPushButton, QLCDNumber, QLabel, QTextEdit, QLayout, QGridLayout, QLayoutItem from typing import Union, Optional, List, Any, Sequence from .binder import * @@ -275,14 +276,12 @@ def getComponentData(component: QWidget) -> Any: elif isinstance(component, NetworkInterfaceSelector): return component.currentSelect() elif isinstance(component, QComboBox): - # noinspection PyTypeChecker return component.currentText() if component.property("format") == "text" else component.currentIndex() elif isinstance(component, QCheckBox): return component.isChecked() elif isinstance(component, QRadioButton): return component.isChecked() elif isinstance(component, QLineEdit): - # noinspection PyTypeChecker return { "int": str2number(component.text()), "float": str2float(component.text()) @@ -298,7 +297,6 @@ def getComponentData(component: QWidget) -> Any: elif isinstance(component, QLCDNumber): return component.value() elif isinstance(component, QPushButton): - # noinspection PyTypeChecker return component.property(ComponentManager.QPushButtonPrivateDataKey) else: return "" @@ -342,7 +340,6 @@ def setComponentData(component: QWidget, data: Any): elif isinstance(component, QLCDNumber): component.display(str2float(data)) elif isinstance(component, QPushButton): - # noinspection PyTypeChecker component.setProperty(ComponentManager.QPushButtonPrivateDataKey, data) @staticmethod @@ -518,7 +515,6 @@ def getByValue(self, key: str, value: Any, # Search by property for component in self.__getComponentsWithType(componentType): - # noinspection PyTypeChecker if component.property(key) == value: return component @@ -538,7 +534,6 @@ def findKey(self, key: str, componentType: Optional[QWidget.__class__] = None) - lst = list() for component in self.__getComponentsWithType(componentType): - # noinspection PyTypeChecker if component.property(key) is not None: lst.append(component) @@ -554,7 +549,6 @@ def findValue(self, key: str, searchValue: Any, componentType: Optional[QWidget. """ lst = list() for component in self.findKey(key, componentType): - # noinspection PyTypeChecker value = component.property(key) if isinstance(value, str) and searchValue in value or value == searchValue: lst.append(component) @@ -576,7 +570,6 @@ def getData(self, key: str, components = self.findKey(key, componentTypes) for component in components: - # noinspection PyTypeChecker value = component.property(key) if value in exclude: @@ -591,7 +584,6 @@ def setData(self, key: str, data: Union[str, dict]) -> bool: return False for component in self.getAll(): - # noinspection PyTypeChecker property_key = component.property(key) value = data.get(property_key) diff --git a/gui/dialog.py b/gui/dialog.py index 0790015..2fd0e4c 100644 --- a/gui/dialog.py +++ b/gui/dialog.py @@ -80,7 +80,6 @@ def __initUi(self, without_buttons: bool): self.__depth.setTickInterval(10) self.__depth.setTickPosition(QSlider.TicksBelow) self.__depth.valueChanged.connect(self.slotChangeDepth) - # noinspection PyTypeChecker depthLayout.addWidget(QLabel(self.tr("Luminance"))) depthLayout.addWidget(self.__depth) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) @@ -93,7 +92,6 @@ def __initUi(self, without_buttons: bool): self.__green = QSpinBox() self.__blue = QSpinBox() valueLayout = QHBoxLayout() - # noinspection PyTypeChecker for text, spinbox in ( (self.tr("Red"), self.__red), (self.tr("Green"), self.__green), (self.tr("Blue"), self.__blue) ): @@ -119,7 +117,6 @@ def __initUi(self, without_buttons: bool): layout.addWidget(button) self.setLayout(layout) - # noinspection PyTypeChecker self.setWindowTitle(self.tr("Please select color")) def __getColor(self) -> Color: @@ -265,7 +262,6 @@ def __init__(self, timeout: float = 0.04, parent: Optional[QWidget] = None): layout.addWidget(button) self.setLayout(layout) self.setFixedSize(self.sizeHint()) - # noinspection PyTypeChecker self.setWindowTitle(self.tr("Please select serial port")) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) @@ -301,7 +297,6 @@ def __init__(self, settings: dict = SerialPortSettingWidget.DEFAULTS, parent: Op self.setLayout(layout) self.setFixedSize(self.sizeHint()) - # noinspection PyTypeChecker self.setWindowTitle(self.tr("Serial Configuration Dialog")) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) @@ -333,7 +328,6 @@ def __init__(self, port: int, timeout: float = 0.04, network: str = '', parent: layout.addWidget(button) self.setLayout(layout) self.setFixedSize(self.sizeHint()) - # noinspection PyTypeChecker self.setWindowTitle(self.tr("Please select address")) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) @@ -370,7 +364,6 @@ def __init__(self, name: str = "", address: str = "", network: str = "", layout.addWidget(button) self.setLayout(layout) self.setFixedSize(self.sizeHint()) - # noinspection PyTypeChecker self.setWindowTitle(self.tr("Please Select Network Interface")) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) @@ -414,7 +407,6 @@ def getInterfaceNetwork(cls, name: str = "", class ProgressDialog(QProgressDialog): progressCanceled = Signal(bool) - # noinspection PyTypeChecker DEF_TITLE = QApplication.translate("ProgressDialog", "Operation progress", None) def __init__(self, parent: QWidget, title: str = DEF_TITLE, max_width: int = 350, @@ -427,14 +419,12 @@ def __init__(self, parent: QWidget, title: str = DEF_TITLE, max_width: int = 350 self.__cancelable = cancelable self.setFixedWidth(max_width) self.setWindowModality(Qt.WindowModal) - # noinspection PyTypeChecker self.setWindowTitle(self.tr(title)) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) if cancel_button is None: # noinspection PyTypeChecker self.setCancelButton(None) else: - # noinspection PyTypeChecker self.setCancelButtonText(self.tr(cancel_button)) def closeEvent(self, ev: QCloseEvent): @@ -442,9 +432,7 @@ def closeEvent(self, ev: QCloseEvent): ev.ignore() if self.__cancelable: - # noinspection PyTypeChecker if showQuestionBox(self, self.tr("Cancel") + " " + self.windowTitle() + " ?"): - # noinspection PyTypeChecker self.setLabelText(self.tr("Canceling please wait...")) self.setCancelState(True) @@ -523,7 +511,6 @@ def __init__(self, widget_cls: Union[BasicJsonSettingWidget.__class__, MultiTabJ try: title = settings.layout.get_name() if isinstance(settings.layout, UiLayout) else settings.layout.get("name") except AttributeError: - # noinspection PyTypeChecker title = self.tr("Configuration Dialog") self.setLayout(layout) @@ -531,7 +518,6 @@ def __init__(self, widget_cls: Union[BasicJsonSettingWidget.__class__, MultiTabJ self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) def tr(self, text: str) -> str: - # noinspection PyTypeChecker return QApplication.translate("BasicJsonSettingDialog", text, None) def getJsonData(self) -> Optional[dict]: @@ -653,20 +639,16 @@ def __init__(self, password: Optional[str] = None, def __initUi(self): # Ui elements self.ui_old_password = QLineEdit() - # noinspection PyTypeChecker self.ui_old_password.setPlaceholderText(self.tr("Please input old password")) self.ui_new_password = QLineEdit() - # noinspection PyTypeChecker self.ui_new_password.setPlaceholderText(self.tr("Please input new password")) self.ui_show_password = QCheckBox() self.ui_confirm_password = QLineEdit() - # noinspection PyTypeChecker self.ui_confirm_password.setPlaceholderText(self.tr("Confirm new password")) - # noinspection PyTypeChecker self.ui_old_password_label = QLabel(self.tr("Old password")) self.ui_buttons = QDialogButtonBox(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) @@ -675,18 +657,15 @@ def __initUi(self): item_layout.addWidget(self.ui_old_password_label, 0, 0) item_layout.addWidget(self.ui_old_password, 0, 1) - # noinspection PyTypeChecker item_layout.addWidget(QLabel(self.tr("New password")), 1, 0) item_layout.addWidget(self.ui_new_password, 1, 1) - # noinspection PyTypeChecker item_layout.addWidget(QLabel(self.tr("Confirm new password")), 2, 0) item_layout.addWidget(self.ui_confirm_password, 2, 1) sub_layout = QHBoxLayout() sub_layout.addWidget(self.ui_show_password) self.ui_show_password.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred) - # noinspection PyTypeChecker sub_layout.addWidget(QLabel(self.tr("Show password"))) item_layout.addLayout(sub_layout, 3, 1) @@ -698,10 +677,8 @@ def __initUi(self): # Mode switch if self.__password: - # noinspection PyTypeChecker self.setWindowTitle(self.tr("Change password")) else: - # noinspection PyTypeChecker self.setWindowTitle(self.tr("Reset password")) self.ui_old_password.setHidden(True) self.ui_old_password_label.setHidden(True) @@ -730,15 +707,12 @@ def accept(self, *args, **kwargs): confirm = self.__hash_function(self.ui_confirm_password.text().encode()) if self.__password and old != self.__password: - # noinspection PyTypeChecker return showMessageBox(self, MB_TYPE_ERR, self.tr("Old password error, please retry")) if new != confirm: - # noinspection PyTypeChecker return showMessageBox(self, MB_TYPE_ERR, self.tr("New password mismatch, please retry")) if len(self.ui_new_password.text()) == 0 or len(self.ui_confirm_password.text()) == 0: - # noinspection PyTypeChecker return showMessageBox(self, MB_TYPE_ERR, self.tr("Password can't be empty, please retry!")) self.__new_password = new @@ -766,7 +740,6 @@ def changePassword(password: Optional[str] = None, class OptionDialog(QDialog): - # noinspection PyTypeChecker DEF_TITLE = QApplication.translate("OptionDialog", "Please select", None) def __init__(self, options: Sequence[str], title: str = DEF_TITLE, parent: Optional[QWidget] = None): @@ -781,7 +754,6 @@ def __init__(self, options: Sequence[str], title: str = DEF_TITLE, parent: Optio layout.addWidget(btn) btn.clicked.connect(self.slotSelected) - # noinspection PyTypeChecker cancel = QPushButton(self.tr("Cancel")) cancel.clicked.connect(self.reject) layout.addWidget(cancel) @@ -820,7 +792,6 @@ def getOptionIndex(cls, options: Sequence[str], title: str = DEF_TITLE, parent: return dialog.getSelectionIndex() -# noinspection PyTypeChecker def showFileExportDialog(parent: QWidget, fmt: str, name: str = "", title: str = QApplication.translate("dialog", "Please select export file save path", @@ -832,7 +803,6 @@ def showFileExportDialog(parent: QWidget, fmt: str, name: str = "", return path -# noinspection PyTypeChecker def showFileImportDialog(parent: QWidget, fmt: str, path: str = "", title: str = QApplication.translate("dialog", "Please select import file", diff --git a/gui/mailbox.py b/gui/mailbox.py index b8c54e0..3a365f2 100644 --- a/gui/mailbox.py +++ b/gui/mailbox.py @@ -240,7 +240,6 @@ def mailProcess(self, mail: BaseUiMail) -> bool: color = "rgb({0:d},{1:d},{2:d})".format(mail.color.red(), mail.color.green(), mail.color.blue()) # Main windows has status bar if isinstance(self.__parent.ui.statusbar, QStatusBar): - # noinspection PyTypeChecker self.__parent.ui.statusbar.showMessage(self.tr(mail.content), mail.timeout) self.__parent.ui.statusbar.setStyleSheet( "QStatusBar{" @@ -250,7 +249,6 @@ def mailProcess(self, mail: BaseUiMail) -> bool: "font-weight:bold;}" % color) # Widget has label named as statusbar elif isinstance(self.__parent.ui.statusbar, QLabel): - # noinspection PyTypeChecker self.__parent.ui.statusbar.setText(self.tr(mail.content)) self.__parent.ui.statusbar.setStyleSheet( "color:{0:s};padding-top:8px;font-weight:bold;".format(color) @@ -287,7 +285,6 @@ def mailProcess(self, mail: BaseUiMail) -> bool: # Appended a message on window title elif isinstance(mail, WindowsTitleMail): - # noinspection PyTypeChecker self.__parent.setWindowTitle(self.__parent.windowTitle() + self.tr(" {0:s}".format(mail.content))) # Callback function diff --git a/gui/misc.py b/gui/misc.py index 0ab0728..4903fa3 100644 --- a/gui/misc.py +++ b/gui/misc.py @@ -28,7 +28,6 @@ class SerialPortSelector(QComboBox): """ # When port selected this signal will emit portSelected = Signal(object) - # noinspection PyTypeChecker TIPS = QApplication.translate("SerialPortSelector", "Please select serial port", None) def __init__(self, text: Optional[str] = TIPS, one_shot: bool = False, parent: Optional[QWidget] = None): @@ -44,7 +43,6 @@ def __init__(self, text: Optional[str] = TIPS, one_shot: bool = False, parent: O self.__text = text self.__one_shot = one_shot self.__system = platform.system().lower() - # noinspection PyTypeChecker self.setToolTip(self.tr("Right click reset and refresh serial port")) # Flush current serial port list @@ -77,7 +75,6 @@ def flushSerialPort(self, timeout: float = 0.04): self.setEnabled(True) if self.__text: - # noinspection PyTypeChecker self.addItem(self.tr(self.__text)) # Scan local system serial port @@ -121,7 +118,6 @@ class NetworkInterfaceSelector(QComboBox): addressChanged = Signal(object) """List current system exist network interface""" - # noinspection PyTypeChecker TIPS = QApplication.translate("NetworkInterfaceSelector", "Please select network interface", None) def __init__(self, text: Optional[str] = TIPS, one_short: bool = False, @@ -131,7 +127,6 @@ def __init__(self, text: Optional[str] = TIPS, one_short: bool = False, self._text = text self._one_short = one_short self._ignore_loopback = ignore_loopback - # noinspection PyTypeChecker self.setToolTip(self.tr("Right click reset and refresh network interface")) self.flushNic() @@ -149,15 +144,12 @@ def flushNic(self): self.addItem("{}: {}".format(nic_name, nic_attr.ip), nic_attr.network) def isNetworkMode(self) -> bool: - # noinspection PyTypeChecker return self.property("format") == "network" def setNetworkMode(self): - # noinspection PyTypeChecker self.setProperty("format", "network") def setAddressMode(self): - # noinspection PyTypeChecker self.setProperty("format", "address") def slotNicSelected(self, idx: int) -> bool: @@ -567,7 +559,6 @@ def paintEvent(self, ev: QPaintEvent): painter.setFont(self.font()) painter.setPen(QPen(self._color)) - # noinspection PyTypeChecker painter.drawText(self.rect(), self._align, self._text) def sizeHint(self) -> QSize: diff --git a/gui/msgbox.py b/gui/msgbox.py index 1d3be02..0d03af9 100644 --- a/gui/msgbox.py +++ b/gui/msgbox.py @@ -33,7 +33,6 @@ def showMessageBox(parent: QWidget, msg_type: str, content: str, title: str = '' :param title: Message title :return: result """ - # noinspection PyTypeChecker attributes = { MB_TYPE_ERR: (QMessageBox.Critical, QApplication.translate("msgbox", "Error", None)), MB_TYPE_WARN: (QMessageBox.Warning, QApplication.translate("msgbox", "Warning", None)), diff --git a/gui/srm.py b/gui/srm.py index ab637da..dba58fb 100644 --- a/gui/srm.py +++ b/gui/srm.py @@ -49,7 +49,6 @@ def __getRawRSAPrivateKey(self, key: bytes) -> str: return self.__decrypt(key) if hasattr(self.__decrypt, '__call__') else key.decode() def tr(self, text: str) -> str: - # noinspection PyTypeChecker return QApplication.translate("SoftwareRegistrationMachineWidget", text, None) def _initUi(self): @@ -232,7 +231,6 @@ def __init__(self, rsa_public_key: str, register_file: str, self.__initData() self.__initSignalAndSlot() - # noinspection PyTypeChecker def __initUi(self): self.ui_save_mc = QPushButton(self.tr("Save Machine Code")) self.ui_load_rc = QPushButton(self.tr("Load Registration Code")) @@ -264,9 +262,7 @@ def __initData(self): self.ui_save_mc.setHidden(True) self.ui_load_rc.setHidden(True) self.ui_backup_rc.setHidden(True) - # noinspection PyTypeChecker self.ui_mc_image.drawFromText(self.tr("Generating please wait...")) - # noinspection PyTypeChecker self.ui_rc_image.drawFromText(self.tr("Please Load Registration Code")) # Display machine code @@ -294,7 +290,6 @@ def isRegistered(self) -> bool: return self.__registered.data def slotSaveMachineCode(self): - # noinspection PyTypeChecker path = showFileExportDialog(self, fmt=self.QR_CODE_FS_FMT, name="machine_code.png", title=self.tr("Please select machine code save path")) if not path: @@ -304,31 +299,25 @@ def slotSaveMachineCode(self): with open(path, 'wb') as fp: fp.write(self.__mc_qr_image) - # noinspection PyTypeChecker self.signalMsgBox.emit(MB_TYPE_INFO, self.tr("Machine code save success") + "\n{!r}".format(path)) except OSError as e: - # noinspection PyTypeChecker showMessageBox(self, MB_TYPE_ERR, self.tr("Save machine code error") + ": {}".format(e)) def slotLoadRegistrationCode(self): if self.__registered: - # noinspection PyTypeChecker return showMessageBox(self, MB_TYPE_INFO, self.tr("Software registered")) - # noinspection PyTypeChecker path = showFileImportDialog(self, fmt=self.QR_CODE_FS_FMT, title=self.tr("Please select registration code")) if not os.path.isfile(path): return - # noinspection PyTypeChecker self.ui_rc_image.drawFromText(self.tr("Verifying, please wait...")) th = threading.Thread(target=self.threadVerifyRegistrationCode, args=(path,)) th.setDaemon(True) th.start() def slotBackupRegistrationCode(self): - # noinspection PyTypeChecker path = showFileExportDialog(self, fmt=self.QR_CODE_FS_FMT, name="registration_code.png", title=self.tr("Please select registration code backup path")) if not path: @@ -338,11 +327,9 @@ def slotBackupRegistrationCode(self): with open(path, "wb") as fp: fp.write(self.__rc_qr_image) - # noinspection PyTypeChecker self.signalMsgBox.emit(MB_TYPE_INFO, self.tr("Software registration code backup success") + "\n{!r}".format(path)) except OSError as e: - # noinspection PyTypeChecker self.signalMsgBox.emit(MB_TYPE_ERR, self.tr("Software registration code backup failed") + ": {}".format(e)) def slotShowMachineCode(self, image: bytes): @@ -357,23 +344,19 @@ def slotShowRegistrationCode(self, verify: bool): self.__registered.data = verify if not verify: - # noinspection PyTypeChecker return showMessageBox(self, MB_TYPE_ERR, self.tr("Invalid software registration code")) self.__rc_qr_image = qrcode_generate(self.__machine.get_registration_code(), fmt=self.QR_CODE_FORMAT) self.ui_rc_image.drawFromMem(self.__rc_qr_image, self.QR_CODE_FORMAT) self.ui_backup_rc.setVisible(True) - # noinspection PyTypeChecker self.ui_load_rc.setText(self.tr("Software registered")) - # noinspection PyTypeChecker showMessageBox(self, MB_TYPE_INFO, self.tr("Software registered")) def threadGenerateMachineCode(self): try: self.signalMachineCodeGenerated.emit(qrcode_generate(self.__machine.get_machine_code())) except Exception as e: - # noinspection PyTypeChecker self.signalMsgBox.emit(MB_TYPE_ERR, self.tr("Generate machine code error") + ": {}".format(e)) def threadVerifyRegistrationCode(self, path: str): @@ -387,7 +370,6 @@ def threadCheckAndLoadRegistrationState(self): self.signalVerifyRegistrationCode.emit(True) else: time.sleep(3) - # noinspection PyTypeChecker self.signalMsgBox.emit(MB_TYPE_WARN, self.tr("Please click 'Load Registration Code' register software")) @staticmethod diff --git a/gui/view.py b/gui/view.py index 9730f59..3a64071 100644 --- a/gui/view.py +++ b/gui/view.py @@ -30,7 +30,6 @@ def __init__(self, parent: Optional[QWidget] = None): self.__columnStretchFactor = list() self.__scale_x, self.__scale_y = get_program_scale_factor() - # noinspection PyTypeChecker for group, actions in { self.COMM_ACTION: [ (QAction(self.tr("Clear All"), self), lambda: self.model().setRowCount(0)), @@ -46,7 +45,6 @@ def __init__(self, parent: Optional[QWidget] = None): }.items(): for action, slot in actions: action.triggered.connect(slot) - # noinspection PyTypeChecker action.setProperty("group", group) self.__contentMenu.addAction(action) @@ -101,7 +99,6 @@ def setCustomContentMenu(self, menu: List[QAction]): if not isinstance(action, QAction): continue - # noinspection PyTypeChecker action.setProperty("group", self.CUSTOM_ACTION) self.__contentMenu.addAction(action) @@ -284,7 +281,6 @@ def setCurrentRow(self, row: int) -> bool: if not isinstance(model, QAbstractItemModel): return False - # noinspection PyTypeChecker return self.setCurrentIndex(model.index(row, 0, QModelIndex())) def setRowCount(self, count: int): @@ -305,7 +301,6 @@ def setTableData(self, data: List[Any], role: Qt.ItemDataRole = Qt.EditRole): if not isinstance(data, list) or len(data) != model.rowCount(): return False - # noinspection PyTypeChecker return sum([self.setRowData(row, data[row], role) for row in range(model.rowCount())]) == len(data) def getRowData(self, row: int, role: Qt.ItemDataRole = Qt.DisplayRole): @@ -360,7 +355,6 @@ def setItemData(self, row: int, column: int, data: Any, role: Qt.ItemDataRole = if not isinstance(model, QAbstractItemModel): return False - # noinspection PyTypeChecker return model.setData(model.index(row, column, QModelIndex()), data, role) def frozenItem(self, row: int, column: int, frozen: bool) -> bool: @@ -382,7 +376,6 @@ def frozenItem(self, row: int, column: int, frozen: bool) -> bool: widget.setCheckable(not frozen) if isinstance(widget, QCheckBox) else widget.setDisabled(frozen) if isinstance(self.itemDelegate(), QItemDelegate): - # noinspection PyTypeChecker self.itemDelegate().setProperty(str(DynamicObject(row=row, column=column)), frozen) return True @@ -536,7 +529,6 @@ def updateColumnDelegate(self, column: int, filter_: UiInputSetting): def isFrozen(self, index: QStyleOptionViewItem) -> bool: row = index.row() column = index.column() - # noinspection PyTypeChecker return self.property(str(DynamicObject(row=row, column=column))) def createEditor(self, parent: QWidget, option: QStyleOptionViewItem, index: QModelIndex): @@ -553,9 +545,7 @@ def createEditor(self, parent: QWidget, option: QStyleOptionViewItem, index: QMo return checkbox elif isinstance(settings, UiPushButtonInput): button = QPushButton(settings.get_name(), parent=parent) - # noinspection PyTypeChecker button.setProperty('private', index.data()) - # noinspection PyTypeChecker button.setProperty('index', index) button.clicked.connect(settings.get_default()) return button diff --git a/gui/widget.py b/gui/widget.py index dccbc28..b0d1ab8 100644 --- a/gui/widget.py +++ b/gui/widget.py @@ -93,7 +93,6 @@ def createInputWithLabel(label: str, key: str, input_cls: QWidget.__class__) -> input_ = input_cls() label = QLabel(label) input_.setProperty("name", key) - # noinspection PyTypeChecker label.setProperty("name", "{}_label".format(key)) return label, input_ @@ -105,7 +104,6 @@ def createMultiInputWithLabel(texts: Iterable[Tuple[str, str]], input_cls: QWidg text = input_cls() label = QLabel(label) text.setProperty("name", key) - # noinspection PyTypeChecker label.setProperty("name", "{}_label".format(key)) layout.addWidget(label, row, 0) layout.addWidget(text, row, 1) @@ -123,11 +121,9 @@ def createButtonGroup(key: str, names: Iterable[str], title: str) -> Tuple[QLabe label = QLabel(title) group = QButtonGroup() layout = QHBoxLayout() - # noinspection PyTypeChecker group.setProperty("name", key) for bid, name in enumerate(names): button = QRadioButton(name) - # noinspection PyTypeChecker button.setProperty("name", name) group.addButton(button) group.setId(button, bid) @@ -932,7 +928,6 @@ def drawFromText(self, text: str, textColor: Union[QColor, Qt.GlobalColor] = Qt. if self.textFont.pointSize() > fontMaxWidth: self.textFont.setPointSize(fontMaxWidth) - # noinspection PyTypeChecker self.text = self.tr(text) self.image = QImage() self.update() @@ -1038,7 +1033,6 @@ def __init__(self, max_column: int, hide_header: bool = False, }.items(): for action, slot in actions: action.triggered.connect(slot) - # noinspection PyTypeChecker action.setProperty("group", group) self.__contentMenu.addAction(action) @@ -1050,7 +1044,6 @@ def __init__(self, max_column: int, hide_header: bool = False, self.setVerticalHeaderHeight(int(self.getVerticalHeaderHeight() * self.__scale_y)) def tr(self, text: str) -> str: - # noinspection PyTypeChecker return QApplication.translate("TableWidget", text, None) def __checkRow(self, row: int) -> bool: @@ -1123,10 +1116,8 @@ def __copyWidget(widget: QWidget) -> QWidget: # Copy widget property for key in widget.dynamicPropertyNames(): key = str(key) - # noinspection PyTypeChecker temp.setProperty(key, widget.property(key)) if key == "clicked" and isinstance(widget, QPushButton): - # noinspection PyTypeChecker temp.clicked.connect(widget.property(key)) return temp @@ -1172,7 +1163,6 @@ def setCustomContentMenu(self, menu: List[QAction]): if not isinstance(action, QAction): continue - # noinspection PyTypeChecker action.setProperty("group", self.ACTION.CUSTOM) self.__contentMenu.addAction(action) @@ -1636,7 +1626,6 @@ def setItemData(self, row: int, column: int, data: Any, property_: Optional[Any] self.removeCellWidget(row, column) self.setCellWidget(row, column, widget) elif isinstance(widget, QPushButton) and isinstance(data, object): - # noinspection PyTypeChecker widget.setProperty("private", data) self.removeCellWidget(row, column) self.setCellWidget(row, column, widget) @@ -1710,7 +1699,6 @@ def setItemDataFilter(self, row: int, column: int, filters: TableDataFilter) -> widget = QDateTimeEdit(dt) widget.setCalendarPopup(True) - # noinspection PyTypeChecker widget.setProperty("format", filters[2]) widget.dateTimeChanged.connect(self.__slotWidgetDataChanged) self.takeItem(row, column) @@ -1719,11 +1707,8 @@ def setItemDataFilter(self, row: int, column: int, filters: TableDataFilter) -> elif len(filters) == 3 and isinstance(filters[0], str) and hasattr(filters[1], "__call__"): button = QPushButton(self.tr(filters[0])) button.clicked.connect(filters[1]) - # noinspection PyTypeChecker button.setProperty("clicked", filters[1]) - # noinspection PyTypeChecker button.setProperty("private", filters[2]) - # noinspection PyTypeChecker button.setProperty("dataChanged", self.__slotWidgetDataChanged) self.takeItem(row, column) self.setCellWidget(row, column, button) @@ -1752,7 +1737,6 @@ def setItemDataFilter(self, row: int, column: int, filters: TableDataFilter) -> value = int(value) except ValueError: value = filters.index(value) if value in filters else 0 - # noinspection PyTypeChecker widget.setProperty("format", "text") widget.setCurrentIndex(value) widget.currentIndexChanged.connect(self.__slotWidgetDataChanged) @@ -1832,13 +1816,10 @@ def getItemData(self, row: int, column: int) -> Any: elif isinstance(widget, QCheckBox): return widget.isChecked() elif isinstance(widget, QComboBox): - # noinspection PyTypeChecker return widget.currentText() if widget.property("format") else widget.currentIndex() elif isinstance(widget, QDateTimeEdit): - # noinspection PyTypeChecker return widget.dateTime().toString(widget.property("format")) elif isinstance(widget, QPushButton): - # noinspection PyTypeChecker return widget.property("private") elif isinstance(widget, QProgressBar): return widget.value() @@ -1905,9 +1886,7 @@ def __init__(self, parent: Optional[QWidget] = None): self.__columnStretchFactor = list() self.ui_context_menu = QMenu(self) - # noinspection PyTypeChecker self.ui_expand_all = QAction(self.tr("Expand All"), self) - # noinspection PyTypeChecker self.ui_collapse_all = QAction(self.tr("Collapse All"), self) self.ui_context_menu.addAction(self.ui_expand_all) @@ -2130,15 +2109,10 @@ def getItemsData(self) -> List[Any]: class SerialPortSettingWidget(QWidget): - # noinspection PyTypeChecker PARITIES_STR = QApplication.translate("SerialPortSettingWidget", "Parity", None) - # noinspection PyTypeChecker DATABITS_STR = QApplication.translate("SerialPortSettingWidget", "DataBits", None) - # noinspection PyTypeChecker STOPBITS_STR = QApplication.translate("SerialPortSettingWidget", "StopBits", None) - # noinspection PyTypeChecker BAUDRATE_STR = QApplication.translate("SerialPortSettingWidget", "BaudRate", None) - # noinspection PyTypeChecker TIMEOUT_STR = QApplication.translate("SerialPortSettingWidget", "Timeout (ms)", None) # Options @@ -2185,14 +2159,12 @@ def __init__(self, settings: Optional[dict] = None, parent: Optional[QWidget] = # If specified port select it port = SerialPortSelector() - # noinspection PyTypeChecker port.setProperty("name", "port") select_port = settings.get("port") if select_port is not None: port.setSelectedPort(select_port) # Add port to dialog - # noinspection PyTypeChecker layout.addWidget(QLabel(self.tr("PortName")), 0, 0) layout.addWidget(port, 0, 1) @@ -2219,9 +2191,7 @@ def __init__(self, settings: Optional[dict] = None, parent: Optional[QWidget] = element.setValue(value) # Set option property - # noinspection PyTypeChecker label = QLabel(self.tr(text)) - # noinspection PyTypeChecker element.setProperty("name", option) # Layout direction setting @@ -2235,14 +2205,12 @@ def getSetting(self) -> Dict[str, Any]: settings = dict() for item in self.__uiManager.findKey("name"): if isinstance(item, QComboBox): - # noinspection PyTypeChecker value = item.property("name") if value == "port" and item.currentIndex() == 0: settings[value] = "" else: settings[value] = item.itemData(item.currentIndex()) elif isinstance(item, QSpinBox): - # noinspection PyTypeChecker settings[item.property("name")] = item.value() return settings @@ -2339,7 +2307,6 @@ def __initUi(self): if not isinstance(widget, VirtualNumberInput): widget.textChanged.connect(self.slotSettingChanged) - # noinspection PyTypeChecker widget.textChanged.connect( lambda x: self.settingChangedDetail.emit(widget.property("data"), x) ) @@ -2414,7 +2381,6 @@ def __initSignalAndSlots(self): preview.textChanged.connect(self.slotPreviewColor) def tr(self, text: str) -> str: - # noinspection PyTypeChecker return QApplication.translate("JsonSettingWidget", text, None) def getSettings(self) -> DynamicObject: @@ -2445,17 +2411,14 @@ def setData(self, data: dict): if isinstance(button, QPushButton): preview = self.ui_manager.getPrevSibling(button) if isinstance(preview, QLineEdit) and data: - # noinspection PyTypeChecker button.setProperty("private", "{}".format(data.get(preview.property("data")))) for button in file_inputs: if isinstance(button, QPushButton): preview = self.ui_manager.getPrevSibling(button) enabled = self.ui_manager.getPrevSibling(preview) - # noinspection PyTypeChecker if isinstance(enabled, QCheckBox) and isinstance(preview, QLineEdit) and \ data and preview.property("data"): - # noinspection PyTypeChecker file_name = preview.property("data") try: enabled, path = data.get(file_name) @@ -2505,9 +2468,7 @@ def slotSelectFont(self): sender = self.sender() if not isinstance(sender, QPushButton): return - # noinspection PyTypeChecker title = self.tr("Please select") + " {}".format(sender.property("title")) - # noinspection PyTypeChecker font_name, point_size, weight = UiFontInput.get_font(sender.property("private")) font, selected = QFontDialog.getFont(QFont(font_name, point_size, weight), self, title) if not selected or not isinstance(font, QFont): @@ -2516,7 +2477,6 @@ def slotSelectFont(self): font_edit = self.ui_manager.getPrevSibling(sender) if isinstance(font_edit, QLineEdit): font_setting = font.rawName(), font.pointSize(), font.weight() - # noinspection PyTypeChecker sender.setProperty("private", "{}".format(font_setting)) font_edit.setText("{}".format(font_setting)) @@ -2556,7 +2516,6 @@ def slotSettingChanged(self): sender = self.sender() # Line edit text content check if isinstance(sender, QLineEdit): - # noinspection PyTypeChecker filters = sender.property("filter") if not filters: return @@ -2586,7 +2545,6 @@ def createInputWidget(setting: UiInputSetting, widget = VirtualNumberInput(parent=parent, initial_value=setting.get_data(), min_=setting.get_check()[UiIntegerInput.CHECK.MIN], max_=setting.get_check()[UiIntegerInput.CHECK.MAX]) - # noinspection PyTypeChecker widget.setProperty("format", "int") else: widget = QSpinBox(parent) @@ -2608,7 +2566,6 @@ def createInputWidget(setting: UiInputSetting, widget.setEchoMode(QLineEdit.Password) # Set regular expression and max length - # noinspection PyTypeChecker widget.setProperty("filter", setting.check[UiTextInput.CHECK.REGEXP]) widget.setValidator(QRegExpValidator(QRegExp(setting.check[UiTextInput.CHECK.REGEXP]))) widget.setMaxLength(setting.check[UiTextInput.CHECK.LENGTH]) @@ -2619,7 +2576,6 @@ def createInputWidget(setting: UiInputSetting, min_=setting.get_check()[UiDoubleInput.CHECK.MIN], max_=setting.get_check()[UiDoubleInput.CHECK.MAX], decimals=setting.get_check()[UiDoubleInput.CHECK.DECIMALS]) - # noinspection PyTypeChecker widget.setProperty("format", "float") else: widget = QDoubleSpinBox(parent) @@ -2634,7 +2590,6 @@ def createInputWidget(setting: UiInputSetting, widget.addItems(setting.get_check()) # Data is text, using text format set and get if isinstance(setting.get_data(), str) and setting.get_data() in setting.get_check(): - # noinspection PyTypeChecker widget.setProperty("format", "text") widget.setCurrentIndex(setting.get_check().index(setting.get_data())) # Data is number, using index format set and get @@ -2648,7 +2603,6 @@ def createInputWidget(setting: UiInputSetting, for id_, text in enumerate(setting.get_check()): btn = QRadioButton(text, parent=parent) - # noinspection PyTypeChecker btn.setProperty("id", id_) group.addButton(btn, id_) layout.addWidget(btn) @@ -2657,12 +2611,10 @@ def createInputWidget(setting: UiInputSetting, text_input = QLineEdit(parent=parent) text_input.setReadOnly(True) text_input.setVisible(False) - # noinspection PyTypeChecker text_input.setProperty("data", name) number_input = QSpinBox(parent=parent) number_input.setVisible(False) - # noinspection PyTypeChecker number_input.setProperty("data", name) # Default select the first item @@ -2686,7 +2638,6 @@ def createInputWidget(setting: UiInputSetting, return layout, group, number_input elif setting.is_serial_type(): widget = SerialPortSelector(parent=parent) - # noinspection PyTypeChecker widget.setProperty("format", "text") widget.setCurrentIndex([widget.itemText(i) for i in range(widget.count())].index(setting.get_data())) elif setting.is_network_type(): @@ -2697,25 +2648,18 @@ def createInputWidget(setting: UiInputSetting, widget.setCurrentAddress(setting.get_data()) elif setting.is_file_type(): widget = QLineEdit(parent) - # noinspection PyTypeChecker widget.setProperty("data", name) widget.setText(setting.get_data()) widget.setReadOnly(not UiFileInput.isEditable(setting.get_check())) - # noinspection PyTypeChecker enable = QCheckBox(QApplication.translate("JsonSettingWidget", "Enable", None), parent=parent) - # noinspection PyTypeChecker enable.setProperty("data", JsonSettingWidget.get_file_input_enable_key(name)) enable.setVisible(UiFileInput.isSelectable(setting.get_check())) - # noinspection PyTypeChecker button = QPushButton(QApplication.translate("JsonSettingWidget", "Please Select File", None), parent=parent) - # noinspection PyTypeChecker button.setProperty("clicked", "file") - # noinspection PyTypeChecker button.setProperty("title", setting.get_name()) - # noinspection PyTypeChecker button.setProperty("private", setting.get_check()[:UiFileInput.CHECK_SELECTABLE]) layout = QHBoxLayout() @@ -2726,18 +2670,13 @@ def createInputWidget(setting: UiInputSetting, elif setting.is_folder_type(): widget = QLineEdit(parent) widget.setReadOnly(True) - # noinspection PyTypeChecker widget.setProperty("data", name) widget.setText(setting.get_data()) - # noinspection PyTypeChecker button = QPushButton(QApplication.translate("JsonSettingWidget", "Please Select Directory", None), parent=parent) - # noinspection PyTypeChecker button.setProperty("clicked", "folder") - # noinspection PyTypeChecker button.setProperty("title", setting.get_name()) - # noinspection PyTypeChecker button.setProperty("private", setting.get_check()) layout = QHBoxLayout() @@ -2747,20 +2686,15 @@ def createInputWidget(setting: UiInputSetting, elif setting.is_font_type(): widget = QLineEdit(parent) widget.setReadOnly(True) - # noinspection PyTypeChecker widget.setProperty("data", name) widget.setText(setting.get_data()) widget.setStyleSheet(UiFontInput.get_stylesheet(setting.get_data())) - # noinspection PyTypeChecker button = QPushButton(QApplication.translate("JsonSettingWidget", "Please Select Font", None), parent=parent) - # noinspection PyTypeChecker button.setProperty("clicked", "font") - # noinspection PyTypeChecker button.setProperty("title", setting.get_name()) - # noinspection PyTypeChecker button.setProperty("private", setting.get_data()) layout = QHBoxLayout() @@ -2771,20 +2705,15 @@ def createInputWidget(setting: UiInputSetting, color = setting.get_data() widget = QLineEdit(parent) widget.setReadOnly(True) - # noinspection PyTypeChecker widget.setProperty("data", name) widget.setText("{}".format(setting.get_data())) widget.setStyleSheet("background-color: rgb{}; color: rgb{};".format(color, color)) - # noinspection PyTypeChecker button = QPushButton(QApplication.translate("JsonSettingWidget", "Please Select Color", None), parent=parent) - # noinspection PyTypeChecker button.setProperty("clicked", "color") - # noinspection PyTypeChecker button.setProperty("title", setting.get_name()) - # noinspection PyTypeChecker button.setProperty("private", setting.get_data()) layout = QHBoxLayout() @@ -2796,7 +2725,6 @@ def createInputWidget(setting: UiInputSetting, # Set property for ComponentManager get data if isinstance(name, str) and isinstance(widget, QWidget): - # noinspection PyTypeChecker widget.setProperty("data", name) # Set readonly option @@ -2851,11 +2779,9 @@ def __initUi(self): elif ui_input.is_select_type(): table_filters[column] = ui_input.get_check() elif ui_input.is_file_type(): - # noinspection PyTypeChecker text = self.tr("Please Select File") table_filters[column] = (text, self.slotSelectFile, ui_input.get_check()) elif ui_input.is_folder_type(): - # noinspection PyTypeChecker text = self.tr("Please Select Directory") table_filters[column] = (text, self.slotSelectFolder, ui_input.get_check()) @@ -2905,7 +2831,6 @@ def slotSelectFile(self): file_format = "*" sender = self.sender() from .dialog import showFileImportDialog - # noinspection PyTypeChecker path = showFileImportDialog(parent=self, title=self.tr("Please Select File"), fmt=self.tr(file_format)) if not os.path.isfile(path): return @@ -2914,7 +2839,6 @@ def slotSelectFile(self): def slotSelectFolder(self): sender = self.sender() - # noinspection PyTypeChecker path = QFileDialog.getExistingDirectory(self, self.tr("Please Select Directory"), "") if not os.path.isdir(path): return @@ -2927,7 +2851,6 @@ def slotSettingChanged(self): sender = self.sender() # Line edit text content check if isinstance(sender, QLineEdit): - # noinspection PyTypeChecker filters = sender.property("filter") try: re.search(filters, sender.text(), re.S).group(0) @@ -2982,7 +2905,6 @@ def __initUi(self): settings[item_name] = self.settings.get(item_name) box_widget = JsonSettingWidget(DynamicObject(**settings)) - # noinspection PyTypeChecker box_widget.setProperty("name", group_settings.get_name()) group_layout.addWidget(box_widget) box.setLayout(group_layout) @@ -3094,7 +3016,6 @@ def __initUi(self): settings[item] = self.settings.get(item) widget = MultiGroupJsonSettingsWidget(DynamicObject(**settings), dict()) - # noinspection PyTypeChecker widget.setProperty('name', tab_setting.name) self.widget_list.append(widget) @@ -3213,13 +3134,9 @@ def __init__(self, filename: str, log_format: str = "%(asctime)s %(levelname)s % # Context menu self.ui_context_menu = QMenu(self) - # noinspection PyTypeChecker self.ui_show_info = QAction(self.tr("Show Info"), self) - # noinspection PyTypeChecker self.ui_show_debug = QAction(self.tr("Show Debug"), self) - # noinspection PyTypeChecker self.ui_show_error = QAction(self.tr("Show Error"), self) - # noinspection PyTypeChecker self.ui_clean_action = QAction(self.tr("Clear All"), self) self.ui_context_menu.addAction(self.ui_clean_action)