Skip to content

Commit 460201d

Browse files
committed
Make _manipulator_data raise error instead of return None
1 parent ef76c80 commit 460201d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/ephys_link/bindings/parallax_binding.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def get_dimensions(self) -> Vector4:
6666

6767
@override
6868
async def get_position(self, manipulator_id: str) -> Vector4:
69-
manipulator_data: dict[str, Any] = await self._manipulator_data(manipulator_id)
69+
manipulator_data: dict[str, Any] = await self._manipulator_data(manipulator_id) # pyright: ignore [reportExplicitAny]
7070
global_z = float(manipulator_data.get("global_Z", 0.0) or 0.0)
7171

7272
await sleep(self.SERVER_DATA_UPDATE_RATE) # Wait for the stage to stabilize.
@@ -78,7 +78,7 @@ async def get_position(self, manipulator_id: str) -> Vector4:
7878

7979
@override
8080
async def get_angles(self, manipulator_id: str) -> Vector3:
81-
manipulator_data: dict[str, Any] = await self._manipulator_data(manipulator_id)
81+
manipulator_data: dict[str, Any] = await self._manipulator_data(manipulator_id) # pyright: ignore [reportExplicitAny]
8282

8383
yaw = int(manipulator_data.get("yaw", 0) or 0)
8484
pitch = int(manipulator_data.get("pitch", 90) or 90)
@@ -88,7 +88,7 @@ async def get_angles(self, manipulator_id: str) -> Vector3:
8888

8989
@override
9090
async def get_shank_count(self, manipulator_id: str) -> int:
91-
manipulator_data: dict[str, Any] = await self._manipulator_data(manipulator_id)
91+
manipulator_data: dict[str, Any] = await self._manipulator_data(manipulator_id) # pyright: ignore [reportExplicitAny]
9292
return int(manipulator_data.get("shank_cnt", 1) or 1)
9393

9494
@staticmethod
@@ -261,8 +261,11 @@ async def _manipulator_data(self, manipulator_id: str) -> dict[str, Any]: # pyr
261261
data = await self._query_data()
262262

263263
if manipulator_id in data:
264-
return data[manipulator_id]
265-
return None
264+
return data[manipulator_id] # pyright: ignore [reportAny]
265+
266+
# If we get here, that means the manipulator doesn't exist.
267+
error_message = f"Manipulator {manipulator_id} not found."
268+
raise ValueError(error_message)
266269

267270
async def _put_request(self, request: dict[str, Any]) -> None: # pyright: ignore [reportExplicitAny]
268271
_ = await get_running_loop().run_in_executor(None, put, self._url, dumps(request))

0 commit comments

Comments
 (0)