Skip to content

Commit

Permalink
mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdwetering committed Jan 21, 2025
1 parent 35f8cda commit 99e0465
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
8 changes: 5 additions & 3 deletions zxlive/base_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ def __init__(self, *actions: QAction) -> None:

# Use box layout that fills the entire tab
self.setLayout(QVBoxLayout())
self.layout().setSpacing(0)
layout = self.layout()
assert layout is not None # for mypy
layout.setSpacing(0)
self.toolbar = QToolBar()
self.layout().addWidget(self.toolbar)
layout.addWidget(self.toolbar)

self.splitter = QSplitter(self)
self.layout().addWidget(self.splitter)
layout.addWidget(self.splitter)
self.splitter.splitterMoved.connect(self.sync_splitter_sizes)

self.file_path = None
Expand Down
1 change: 1 addition & 0 deletions zxlive/editor_base_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ def add_item(self, name: str) -> None:
combobox.setCurrentIndex(0)
combobox.currentTextChanged.connect(lambda text: self._text_changed(name, text))
item = self._layout.itemAtPosition(2 + self._items, 2)
assert item is not None # For mypy
self._layout.removeItem(item)
self._layout.addWidget(QLabel(f"<pre>{name}</pre>"), 2 + self._items, 0, Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignRight)
self._layout.addWidget(combobox, 2 + self._items, 2, Qt.AlignmentFlag.AlignCenter)
Expand Down
12 changes: 7 additions & 5 deletions zxlive/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ def __init__(self) -> None:
w = QWidget(self)
w.setLayout(QVBoxLayout())
self.setCentralWidget(w)
w.layout().setContentsMargins(0, 0, 0, 0)
w.layout().setSpacing(0)
wlayout = w.layout()
assert wlayout is not None # for mypy
wlayout.setContentsMargins(0, 0, 0, 0)
wlayout.setSpacing(0)
self.resize(1200, 800)

# restore the window from the last time it was opened
Expand All @@ -74,7 +76,7 @@ def __init__(self) -> None:
self.show()

tab_widget = QTabWidget(self)
w.layout().addWidget(tab_widget)
wlayout.addWidget(tab_widget)
tab_widget.setTabsClosable(True)
tab_widget.currentChanged.connect(self.tab_changed)
tab_widget.tabCloseRequested.connect(self.close_tab)
Expand Down Expand Up @@ -339,7 +341,7 @@ def close_tab(self, i: int) -> bool:
name = self.tab_widget.tabText(i).replace("*","")
answer = QMessageBox.question(self, "Save Changes",
f"Do you wish to save your changes to {name} before closing?",
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No | QMessageBox.StandardButton.Cancel)
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No | QMessageBox.StandardButton.Cancel) # type: ignore
if answer == QMessageBox.StandardButton.Cancel:
return False
if answer == QMessageBox.StandardButton.Yes:
Expand Down Expand Up @@ -584,7 +586,7 @@ def format_str(c: complex) -> str:
table.resizeColumnsToContents()
table.resizeRowsToContents()
dialog.setLayout(QVBoxLayout())
dialog.layout().addWidget(table)
dialog.layout().addWidget(table) # type: ignore # mypy thinks this can be None
dialog.exec()

def proof_as_lemma(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion zxlive/vitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def mouseReleaseEvent(self, e: QGraphicsSceneMouseEvent) -> None:
e.ignore()
return
if e.button() == Qt.MouseButton.LeftButton:
if self._old_pos != self.pos():
if self._old_pos is None or self._old_pos != self.pos():
if self.ty == VertexType.W_INPUT:
# set the position of w_in to next to w_out at the same angle
w_out = get_w_partner_vitem(self)
Expand Down

0 comments on commit 99e0465

Please sign in to comment.