fix: clear basedpyright diff violations
Rename NumberLineEdit.validator to range_validator: the instance attr shadowed QLineEdit.validator() and broke type checking at call sites. Annotate the smargon _move_axes dict and cast the stand-in self in the prediction subscriber test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b4896105ab
commit
5871c959e2
4 files changed
+17
-12
No files matched your search
@@ -109,7 +109,7 @@ class SmargonPanel(QWidget):
|
||||
self.smargon.emit(SmargonCoordinate(sh_mm=Coordinate(x=0, y=0, z=18), phi_deg=0, chi_deg=0))
|
||||
|
||||
@Slot(dict)
|
||||
def _move_axes(self, targets: dict):
|
||||
def _move_axes(self, targets: dict[str, float]):
|
||||
# only the staged axes move — absent keys stay None (no motion)
|
||||
self.smargon.emit(SmargonCoordinate(chi_deg=targets.get("chi"), phi_deg=targets.get("phi")))
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ class MotorMoveGroup(QObject):
|
||||
# incomplete entry ("", "-", "1e"): stay/become pending, no tips
|
||||
self._set_state(name, "pending")
|
||||
return
|
||||
top = box.validator.top()
|
||||
top = box.range_validator.top()
|
||||
if value > top:
|
||||
QToolTip.showText(
|
||||
box.mapToGlobal(QPoint(0, box.height())),
|
||||
@@ -96,7 +96,7 @@ class MotorMoveGroup(QObject):
|
||||
value = float(box.text())
|
||||
except ValueError:
|
||||
break
|
||||
bottom = box.validator.bottom()
|
||||
bottom = box.range_validator.bottom()
|
||||
if value < bottom:
|
||||
QToolTip.showText(
|
||||
box.mapToGlobal(QPoint(0, box.height())),
|
||||
|
||||
@@ -17,12 +17,14 @@ class NumberLineEdit(QLineEdit):
|
||||
self._read_only: bool = False
|
||||
self._is_valid: bool = True
|
||||
|
||||
# Use a QDoubleValidator to only allow valid floating point numbers
|
||||
self.validator = QDoubleValidator()
|
||||
self.validator.setNotation(QDoubleValidator.Notation.StandardNotation)
|
||||
# Use a QDoubleValidator to only allow valid floating point numbers.
|
||||
# Named range_validator: plain "validator" would shadow
|
||||
# QLineEdit.validator() and break type checking at call sites.
|
||||
self.range_validator = QDoubleValidator()
|
||||
self.range_validator.setNotation(QDoubleValidator.Notation.StandardNotation)
|
||||
self.decimal_count = decimals
|
||||
self.validator.setRange(min_val, max_val, self.decimal_count)
|
||||
self.setValidator(self.validator)
|
||||
self.range_validator.setRange(min_val, max_val, self.decimal_count)
|
||||
self.setValidator(self.range_validator)
|
||||
self.setAlignment(Qt.AlignmentFlag.AlignRight)
|
||||
self.setToolTip(
|
||||
f"Minimum: {self.to_string(min_val):s}\nMaximum: {self.to_string(max_val):s}"
|
||||
@@ -80,13 +82,13 @@ class NumberLineEdit(QLineEdit):
|
||||
|
||||
@Slot(float, float)
|
||||
def update_limits(self, min_val: float, max_val: float):
|
||||
self.validator.setRange(min_val, max_val, self.decimal_count)
|
||||
self.range_validator.setRange(min_val, max_val, self.decimal_count)
|
||||
self.setToolTip(
|
||||
f"Minimum: {self.to_string(min_val):s}\nMaximum: {self.to_string(max_val):s}"
|
||||
)
|
||||
|
||||
def validate(self, text) -> bool:
|
||||
return self.validator.validate(str(text), 0)[0] == QDoubleValidator.State.Acceptable
|
||||
return self.range_validator.validate(str(text), 0)[0] == QDoubleValidator.State.Acceptable
|
||||
|
||||
def setReadOnly(self, ro: bool):
|
||||
# Colors follow via the QSS :read-only pseudo-class (updates without
|
||||
|
||||
@@ -2,13 +2,16 @@
|
||||
byte) must be rejected without attempting utf-8 decode (previously raised
|
||||
UnicodeDecodeError on every frame)."""
|
||||
|
||||
from typing import cast
|
||||
|
||||
from aare.gui.threads.prediction_subscriber import PredictionSubscriber
|
||||
|
||||
|
||||
def _parse(part: bytes):
|
||||
# Called unbound: _try_parse_json touches no instance state, so no
|
||||
# QThread/zmq construction is needed.
|
||||
return PredictionSubscriber._try_parse_json(object(), part)
|
||||
# QThread/zmq construction is needed. cast keeps basedpyright happy
|
||||
# about the stand-in self.
|
||||
return PredictionSubscriber._try_parse_json(cast(PredictionSubscriber, object()), part)
|
||||
|
||||
|
||||
def test_binary_jpeg_frame_is_not_json():
|
||||
|
||||
Reference in new issue
Block a user