Skip to content

Commit

Permalink
remove "# noinspection PyTypeChecker"
Browse files Browse the repository at this point in the history
  • Loading branch information
amaork committed Mar 18, 2022
1 parent 286133e commit 365a96c
Show file tree
Hide file tree
Showing 20 changed files with 24 additions and 205 deletions.
11 changes: 0 additions & 11 deletions dashboard/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand All @@ -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))

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion demos/checkbox_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions demos/dashboard_input_test.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions demos/dialog_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 不同)"))
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion demos/event_filter_test.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion demos/monitor_demo.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions demos/status_demo.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,7 +13,6 @@ class DemoDashboardStatus(BasicWidget):
def __init__(self, parent=None):
super(DemoDashboardStatus, self).__init__(parent)

# noinspection PyTypeChecker
def _initUi(self):
layout = QHBoxLayout()

Expand Down
5 changes: 3 additions & 2 deletions demos/tabbar_demo.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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)

Expand Down
16 changes: 8 additions & 8 deletions demos/tarmanager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down
9 changes: 2 additions & 7 deletions demos/widget_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand All @@ -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


Expand Down Expand Up @@ -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)

Expand All @@ -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):
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion gui/binder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
2 changes: 0 additions & 2 deletions gui/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
12 changes: 2 additions & 10 deletions gui/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand Up @@ -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())
Expand All @@ -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 ""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -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:
Expand All @@ -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)

Expand Down
Loading

0 comments on commit 365a96c

Please sign in to comment.