fix: satisfy lint and diff-coverage gates for admin gating
basedpyright requires _admin_tip_anchor to exist after __init__, so the anchor is created eagerly instead of lazily. Cover the red-tip branch and the status-bar menu gate; the menu test swaps in a QMenu subclass with a no-op exec because PySide method lookup ignores class-attr monkeypatches. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -353,6 +353,13 @@ class MainWindow(QMainWindow):
|
||||
# after the docks), not in the left column. Always visible.
|
||||
self.beamline_state_panel = BeamlineStatePanel(staff=self._decoded_token.staff, parent=self)
|
||||
|
||||
# Anchor for _show_admin_tip: QToolTip inherits QSS from the widget
|
||||
# it is shown for, so this hidden label carries the red warning wash
|
||||
# without reddening any other tooltip. Eager, not lazy — basedpyright
|
||||
# requires instance attributes to exist after __init__.
|
||||
self._admin_tip_anchor = QLabel(self)
|
||||
self._admin_tip_anchor.hide()
|
||||
|
||||
# Beamline / Experiment as tabs (like the Dewar samples dock) instead
|
||||
# of two stacked banner groups; the pages keep their banner children.
|
||||
# documentMode: no pane frame, so the fixed-width panels aren't inset.
|
||||
@@ -1477,12 +1484,8 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def _show_admin_tip(self, message: str) -> None:
|
||||
# "Not admin" denials are passive red tips, not QMessageBoxes:
|
||||
# nothing to click away. QToolTip inherits QSS from the widget it is
|
||||
# shown for, so a hidden anchor keeps the red wash off every other
|
||||
# tooltip; styled at show time so it always matches the theme.
|
||||
if not hasattr(self, "_admin_tip_anchor"):
|
||||
self._admin_tip_anchor = QLabel(self)
|
||||
self._admin_tip_anchor.hide()
|
||||
# nothing to click away. Styled at show time so it always matches
|
||||
# the theme.
|
||||
self._admin_tip_anchor.setStyleSheet(admin_tip_qss(self._theme_mode))
|
||||
QToolTip.showText(QCursor.pos(), message, self._admin_tip_anchor)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user