Skip to content

Commit 40ff738

Browse files
committed
fix: fix ClassVar usage in bl_states
1 parent ff410e6 commit 40ff738

2 files changed

Lines changed: 8 additions & 27 deletions

File tree

bec_lib/bec_lib/bl_states.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import traceback
88
from abc import ABC, abstractmethod
99
from dataclasses import dataclass
10-
from typing import Annotated, Any, Callable, Generic, Literal, Type, TypeVar, cast
10+
from typing import Annotated, Any, Callable, ClassVar, Generic, Literal, Type, TypeVar, cast
1111

1212
import yaml
1313
from pydantic import BaseModel, field_validator, model_validator
@@ -59,7 +59,7 @@ class BeamlineStateConfig(BaseModel):
5959
Base Configuration for a beamline state.
6060
"""
6161

62-
state_type: str | None = "BeamlineState"
62+
state_type: ClassVar[str] = "BeamlineState"
6363

6464
name: Annotated[
6565
str,
@@ -92,7 +92,7 @@ class DeviceStateConfig(BeamlineStateConfig):
9292
Configuration for a device-based beamline state.
9393
"""
9494

95-
state_type: str | None = "DeviceBeamlineState"
95+
state_type: ClassVar[str] = "DeviceBeamlineState"
9696

9797
device: Annotated[
9898
DeviceBase | str,
@@ -157,7 +157,7 @@ class DeviceWithinLimitsStateConfig(DeviceStateConfig):
157157
Configuration for a device within limits beamline state.
158158
"""
159159

160-
state_type: str | None = "DeviceWithinLimitsState"
160+
state_type: ClassVar[str] = "DeviceWithinLimitsState"
161161

162162
low_limit: Annotated[
163163
float | None,
@@ -248,7 +248,7 @@ class AggregatedStateConfig(BeamlineStateConfig):
248248
Keys of the states dictionary are the labels of the different states.
249249
"""
250250

251-
state_type: str | None = "AggregatedState"
251+
state_type: ClassVar[str] = "AggregatedState"
252252

253253
states: dict[str, SubDeviceStateConfig]
254254

bec_lib/tests/test_beamline_states.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -208,28 +208,6 @@ def aggregated_state_config(self):
208208
},
209209
)
210210

211-
def test_shutter_state_open_and_closed(self, connected_connector, dm_with_devices):
212-
state = bl_states.ShutterState(
213-
name="shutter_open",
214-
device="samx",
215-
signal="samx",
216-
low_limit=0.0,
217-
high_limit=10.0,
218-
redis_connector=connected_connector,
219-
device_manager=dm_with_devices,
220-
)
221-
state.start()
222-
223-
valid_msg = messages.DeviceMessage(
224-
signals={"samx": {"value": 5.0, "timestamp": 1.0}}, metadata={"stream": "primary"}
225-
)
226-
invalid_msg = messages.DeviceMessage(
227-
signals={"samx": {"value": 11.0, "timestamp": 2.0}}, metadata={"stream": "primary"}
228-
)
229-
230-
assert state.evaluate(valid_msg).status == "valid"
231-
assert state.evaluate(invalid_msg).status == "invalid"
232-
233211
def test_device_within_limits_state_valid_and_invalid(
234212
self, connected_connector, dm_with_devices
235213
):
@@ -294,7 +272,10 @@ def test_device_within_limits_state_accepts_signal_backed_device(
294272
low_limit=-1.0,
295273
high_limit=10.0,
296274
tolerance=0.1,
275+
redis_connector=connected_connector,
276+
device_manager=dm_with_devices,
297277
)
278+
state.start()
298279

299280
msg = messages.DeviceMessage(
300281
signals={"bpm4i": {"value": 5.0, "timestamp": 1.0}}, metadata={"stream": "primary"}

0 commit comments

Comments
 (0)