Skip to content

Commit a3b1b8c

Browse files
authored
Update bluesky and pin pyright (#1072)
* Pin to latest bluesky and fix tests * Remove no longer needed type ignores * Use improved typing on Movable * Fix some typing errors * Unpin bluesky so we use the latest * Pin pyright
1 parent 5893821 commit a3b1b8c

22 files changed

+65
-57
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ dev = [
5555
"pre-commit",
5656
"psutil",
5757
"pydata-sphinx-theme>=0.12",
58-
"pyright",
58+
"pyright==1.1.394", # See https://github.com/DiamondLightSource/dodal/issues/1079
5959
"pytest",
6060
"pytest-asyncio",
6161
"pytest-cov",

src/dodal/devices/aperturescatterguard.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def load_positions_from_beamline_parameters(
123123
}
124124

125125

126-
class ApertureScatterguard(StandardReadable, Movable, Preparable):
126+
class ApertureScatterguard(StandardReadable, Movable[ApertureValue], Preparable):
127127
"""Move the aperture and scatterguard assembly in a safe way. There are two ways to
128128
interact with the device depending on if you want simplicity or move flexibility.
129129

src/dodal/devices/apple2_undulator.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import abc
22
import asyncio
33
from dataclasses import dataclass
4-
from typing import Any
4+
from typing import Any, Generic, TypeVar
55

66
import numpy as np
77
from bluesky.protocols import Movable
@@ -21,6 +21,8 @@
2121

2222
from dodal.log import LOGGER
2323

24+
T = TypeVar("T")
25+
2426

2527
class UndulatorGateStatus(StrictEnum):
2628
OPEN = "Open"
@@ -99,7 +101,7 @@ async def estimate_motor_timeout(
99101
return abs((target_pos - cur_pos) * 2.0 / vel) + 1
100102

101103

102-
class SafeUndulatorMover(StandardReadable, Movable):
104+
class SafeUndulatorMover(StandardReadable, Movable[T], Generic[T]):
103105
"""A device that will check it's safe to move the undulator before moving it and
104106
wait for the undulator to be safe again before calling the move complete.
105107
"""
@@ -115,7 +117,7 @@ def __init__(self, set_move: SignalW, prefix: str, name: str = ""):
115117
super().__init__(name)
116118

117119
@AsyncStatus.wrap
118-
async def set(self, value) -> None:
120+
async def set(self, value: T) -> None:
119121
LOGGER.info(f"Setting {self.name} to {value}")
120122
await self.raise_if_cannot_move()
121123
await self._set_demand_positions(value)
@@ -125,7 +127,7 @@ async def set(self, value) -> None:
125127
await wait_for_value(self.gate, UndulatorGateStatus.CLOSE, timeout=timeout)
126128

127129
@abc.abstractmethod
128-
async def _set_demand_positions(self, value) -> None:
130+
async def _set_demand_positions(self, value: T) -> None:
129131
"""Set the demand positions on the device without actually hitting move."""
130132

131133
@abc.abstractmethod
@@ -139,7 +141,7 @@ async def raise_if_cannot_move(self) -> None:
139141
raise RuntimeError(f"{self.name} is already in motion.")
140142

141143

142-
class UndulatorGap(SafeUndulatorMover):
144+
class UndulatorGap(SafeUndulatorMover[float]):
143145
"""A device with a collection of epics signals to set Apple 2 undulator gap motion.
144146
Only PV used by beamline are added the full list is here:
145147
/dls_sw/work/R3.14.12.7/support/insertionDevice/db/IDGapVelocityControl.template
@@ -185,7 +187,7 @@ def __init__(self, prefix: str, name: str = ""):
185187
self.user_readback = epics_signal_r(float, prefix + "CURRGAPD")
186188
super().__init__(self.set_move, prefix, name)
187189

188-
async def _set_demand_positions(self, value) -> None:
190+
async def _set_demand_positions(self, value: float) -> None:
189191
await self.user_setpoint.set(str(value))
190192

191193
async def get_timeout(self) -> float:
@@ -234,7 +236,7 @@ def __init__(self, prefix: str, infix: str, name: str = ""):
234236
super().__init__(name=name)
235237

236238

237-
class UndulatorPhaseAxes(SafeUndulatorMover):
239+
class UndulatorPhaseAxes(SafeUndulatorMover[Apple2PhasesVal]):
238240
"""
239241
A collection of 4 phase Motor to make up the full id phase motion. We are using the diamond pv convention.
240242
e.g. top_outer == Q1
@@ -290,7 +292,7 @@ async def get_timeout(self) -> float:
290292
return np.max(timeouts)
291293

292294

293-
class UndulatorJawPhase(SafeUndulatorMover):
295+
class UndulatorJawPhase(SafeUndulatorMover[float]):
294296
"""
295297
A JawPhase movable, this is use for moving the jaw phase which is use to control the
296298
linear arbitrary polarisation but only one some of the beamline.

src/dodal/devices/attenuator/attenuator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self, prefix: str, name: str = "") -> None:
2929
super().__init__(name)
3030

3131

32-
class BinaryFilterAttenuator(ReadOnlyAttenuator, Movable):
32+
class BinaryFilterAttenuator(ReadOnlyAttenuator, Movable[float]):
3333
"""The attenuator will insert filters into the beam to reduce its transmission.
3434
In this attenuator, each filter can be in one of two states: IN or OUT
3535

src/dodal/devices/backlight.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class BacklightPosition(StrictEnum):
1515
OUT = "Out"
1616

1717

18-
class Backlight(StandardReadable, Movable):
18+
class Backlight(StandardReadable, Movable[BacklightPosition]):
1919
"""Simple device to trigger the pneumatic in/out."""
2020

2121
TIME_TO_MOVE_S = 1.0 # Tested using a stopwatch on the beamline 09/2024

src/dodal/devices/bimorph_mirror.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class BimorphMirrorStatus(StrictEnum):
4141
ERROR = "Error"
4242

4343

44-
class BimorphMirrorChannel(StandardReadable, Movable, EpicsDevice):
44+
class BimorphMirrorChannel(StandardReadable, Movable[float], EpicsDevice):
4545
"""Collection of PVs comprising a single bimorph channel.
4646
4747
Attributes:
@@ -66,7 +66,7 @@ async def set(self, value: float):
6666
await self.output_voltage.set(value)
6767

6868

69-
class BimorphMirror(StandardReadable, Movable):
69+
class BimorphMirror(StandardReadable, Movable[Mapping[int, float]]):
7070
"""Class to represent CAENels Bimorph Mirrors.
7171
7272
Attributes:

src/dodal/devices/hutch_shutter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async def shutter_safe_to_operate(self) -> bool:
5555
return interlock_state == HUTCH_SAFE_FOR_OPERATIONS
5656

5757

58-
class HutchShutter(StandardReadable, Movable):
58+
class HutchShutter(StandardReadable, Movable[ShutterDemand]):
5959
"""Device to operate the hutch shutter.
6060
6161
When a demand is sent, the device should first check the hutch status \

src/dodal/devices/i10/i10_apple2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def update_lookuptable(self):
175175
self._available_pol = list(self.lookup_tables["Gap"].keys())
176176

177177

178-
class I10Apple2PGM(StandardReadable, Movable):
178+
class I10Apple2PGM(StandardReadable, Movable[float]):
179179
"""
180180
Compound device to set both ID and PGM energy at the sample time,poly_deg
181181
@@ -211,7 +211,7 @@ async def set(self, value: float) -> None:
211211
)
212212

213213

214-
class I10Apple2Pol(StandardReadable, Movable):
214+
class I10Apple2Pol(StandardReadable, Movable[str]):
215215
"""
216216
Compound device to set polorisation of ID.
217217
"""
@@ -240,7 +240,7 @@ async def set(self, value: str) -> None:
240240
) # Move id to new polarisation
241241

242242

243-
class LinearArbitraryAngle(StandardReadable, Movable):
243+
class LinearArbitraryAngle(StandardReadable, Movable[SupportsFloat]):
244244
"""
245245
Device to set polorisation angle of the ID. Linear Arbitrary Angle (laa)
246246
is the direction of the magnetic field which can be change by varying the jaw_phase

src/dodal/devices/i19/shutter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class HutchState(str, Enum):
1818
INVALID = "INVALID"
1919

2020

21-
class HutchConditionalShutter(StandardReadable, Movable):
21+
class HutchConditionalShutter(StandardReadable, Movable[ShutterDemand]):
2222
""" I19-specific device to operate the hutch shutter.
2323
2424
This device evaluates the hutch state value to work out which of the two I19 \

src/dodal/devices/i24/pmac.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async def trigger(self):
7171
await self.signal_ref().set(self.cmd_string, wait=True)
7272

7373

74-
class PMACStringLaser(Device, Movable):
74+
class PMACStringLaser(Device, Movable[LaserSettings]):
7575
"""Set the pmac_string to control the laser."""
7676

7777
def __init__(
@@ -90,7 +90,7 @@ async def set(
9090
await self._signal_ref().set(value.value)
9191

9292

93-
class PMACStringEncReset(Device, Movable):
93+
class PMACStringEncReset(Device, Movable[EncReset]):
9494
"""Set a pmac_string to control the encoder channels in the controller."""
9595

9696
def __init__(

0 commit comments

Comments
 (0)