style: clear the basedpyright gate for the ported round

Declare MainWindow's lazily-set attributes, guard Optional layouts and
the sample tab bar, wrap QSettings reads (typed object even with
type=...), include _press_geom in the pop-out resize guard, and ignore
the PySide6 stub gap on setGraphicsEffect(None).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-11 10:35:46 +02:00
co-authored by Claude Fable 5
parent 0b80c75c63
commit 84ccf275f9
2 changed files with 39 additions and 14 deletions
+38 -13
View File
@@ -112,6 +112,11 @@ logger = setup_logger(LOGGER_NAME)
class MainWindow(QMainWindow):
sample_geometry = Signal(SampleGeometryModel)
# Set lazily outside __init__ (first use guards with getattr/default);
# declared for the basedpyright gate.
_session_operations_enabled: bool | None = None
_default_dock_split_done: bool = False
def __init__(
self,
base_url: str | None,
@@ -125,6 +130,10 @@ class MainWindow(QMainWindow):
):
super().__init__()
# Banners open before a baton-vacancy fold; in __init__ (not a class
# default) so the mutable list is per-instance (RUF012).
self._pre_vacancy_open_banners: list[TitleLabel] = []
self._theme_mode = THEME_ORIGINAL
self._theme_action_group = None
self._use_legacy_theme_action = None
@@ -326,11 +335,15 @@ class MainWindow(QMainWindow):
self.data_collection,
self.data_collection.file_path_panel,
):
m = first.layout().contentsMargins()
first.layout().setContentsMargins(m.left(), 0, m.right(), m.bottom())
first_layout = first.layout()
assert first_layout is not None # panels build their layouts in __init__
m = first_layout.contentsMargins()
first_layout.setContentsMargins(m.left(), 0, m.right(), m.bottom())
samcam_layout = self.samcam.layout()
assert samcam_layout is not None
self.left_column_tabs.setStyleSheet(
"QTabWidget::tab-bar {"
f" left: {self.samcam.layout().contentsMargins().left()}px; }}"
f" left: {samcam_layout.contentsMargins().left()}px; }}"
)
self.left_column_layout.addWidget(self.left_column_tabs)
@@ -1297,13 +1310,21 @@ class MainWindow(QMainWindow):
def _restore_samcam_overlay_settings(self) -> None:
settings = QSettings("PSI", "AareGUI")
show_detections = settings.value("samcam/show_detections", True, type=bool)
show_detection_polygons = settings.value("samcam/show_detection_polygons", True, type=bool)
show_target_point = settings.value("samcam/show_target_point", True, type=bool)
show_target_coordinates = settings.value("samcam/show_target_coordinates", True, type=bool)
show_overlay_legend = settings.value("samcam/show_overlay_legend", True, type=bool)
compact_overlay_legend = settings.value("samcam/compact_overlay_legend", False, type=bool)
target_color = settings.value("samcam/target_color", "Cyan", type=str)
# bool()/str() wraps: QSettings.value is typed "object" even with
# type=..., so the wraps are runtime no-ops for the pyright gate.
show_detections = bool(settings.value("samcam/show_detections", True, type=bool))
show_detection_polygons = bool(
settings.value("samcam/show_detection_polygons", True, type=bool)
)
show_target_point = bool(settings.value("samcam/show_target_point", True, type=bool))
show_target_coordinates = bool(
settings.value("samcam/show_target_coordinates", True, type=bool)
)
show_overlay_legend = bool(settings.value("samcam/show_overlay_legend", True, type=bool))
compact_overlay_legend = bool(
settings.value("samcam/compact_overlay_legend", False, type=bool)
)
target_color = str(settings.value("samcam/target_color", "Cyan", type=str))
self.samcam.apply_overlay_settings(
show_detections=show_detections,
@@ -2305,7 +2326,9 @@ class MainWindow(QMainWindow):
):
widget.setEnabled(owned)
if owned:
widget.setGraphicsEffect(None)
# None clears the effect (Qt API contract); the PySide6 stub
# signature misses the Optional.
widget.setGraphicsEffect(None) # pyright: ignore[reportArgumentType]
else:
# Full grayscale, banners included — QSS :disabled alone
# can't reach the custom-painted TitleLabels/inline styles.
@@ -2819,10 +2842,12 @@ class MainWindow(QMainWindow):
# Non-staff click on the greyed-out Auxiliary-puck tab: only installed
# for non-staff, and tabAt() is geometric so it still sees the
# disabled tab — explain the lock instead of silently eating the click.
sample_tab_bar = self.sample_lists_tabs.tabBar()
if (
event.type() == QEvent.Type.MouseButtonPress
and obj is self.sample_lists_tabs.tabBar()
and obj.tabAt(event.position().toPoint()) == 1
and sample_tab_bar is not None
and obj is sample_tab_bar
and sample_tab_bar.tabAt(event.position().toPoint()) == 1
):
self._show_reference_tools_staff_only_popup()
return True
+1 -1
View File
@@ -183,7 +183,7 @@ class PopoutWindow(QWidget):
super().mousePressEvent(event)
def mouseMoveEvent(self, event):
if self._manual_edges and self._press_global is not None:
if self._manual_edges and self._press_global is not None and self._press_geom is not None:
delta = event.globalPosition().toPoint() - self._press_global
geom = QRect(self._press_geom)
if self._manual_edges & Qt.Edge.LeftEdge: