Skip to content

Commit 7ce01b3

Browse files
committed
Set requires-python
1 parent bc7920c commit 7ce01b3

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ name = "ibex-bluesky-core" # REQUIRED, is the only field that cannot be marked
88
dynamic = ["version"]
99
description = "Core bluesky plan stubs & devices for use at ISIS"
1010
readme = "README.md"
11-
requires-python = ">=3.10"
11+
requires-python = ">=3.11"
1212
license-files = ["LICENSE"]
1313

1414
authors = [

src/ibex_bluesky_core/devices/block.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import asyncio
44
import logging
5-
import sys
65
from collections.abc import Callable
76
from dataclasses import dataclass
87
from typing import Generic, TypeVar
@@ -58,8 +57,6 @@
5857
# looking at the global moving flag.
5958
GLOBAL_MOVING_FLAG_PRE_WAIT = 0.1
6059

61-
aio_timeout_error = asyncio.exceptions.TimeoutError if sys.version_info < (3, 11) else TimeoutError
62-
6360

6461
@dataclass(kw_only=True, frozen=True)
6562
class BlockWriteConfig(Generic[T]):
@@ -286,7 +283,7 @@ async def set_and_settle(setpoint: T) -> None:
286283
else:
287284
try:
288285
await set_and_settle(value)
289-
except aio_timeout_error as e:
286+
except TimeoutError as e:
290287
logger.info(
291288
"block set %s value=%s failed with %s, but continuing anyway because "
292289
"continue_on_failed_write is set.",

tests/devices/test_block.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# pyright: reportMissingParameterType=false
2-
import asyncio
3-
import sys
42
from contextlib import nullcontext
53
from unittest.mock import ANY, MagicMock, call, patch
64

@@ -25,11 +23,6 @@
2523
)
2624
from tests.conftest import MOCK_PREFIX
2725

28-
if sys.version_info < (3, 11):
29-
aio_timeout_error = asyncio.exceptions.TimeoutError
30-
else:
31-
aio_timeout_error = TimeoutError
32-
3326

3427
async def _make_block(clazz):
3528
block = clazz(float, MOCK_PREFIX, "float_block")
@@ -192,7 +185,7 @@ async def test_block_set_with_timeout():
192185

193186
set_mock_value(block.readback, 10)
194187

195-
with pytest.raises(aio_timeout_error):
188+
with pytest.raises(TimeoutError):
196189
await block.set(20)
197190

198191
func.assert_called_once_with(20, 10)
@@ -234,7 +227,7 @@ async def test_block_set_waiting_for_global_moving_flag_timeout():
234227

235228
set_mock_value(block.global_moving, True)
236229
with patch("ibex_bluesky_core.devices.block.asyncio.sleep") as mock_aio_sleep:
237-
with pytest.raises(aio_timeout_error):
230+
with pytest.raises(TimeoutError):
238231
await block.set(10)
239232
# Only check first call, as wait_for_value from ophyd_async gives us a few more...
240233
assert mock_aio_sleep.mock_calls[0] == call(GLOBAL_MOVING_FLAG_PRE_WAIT)
@@ -382,13 +375,13 @@ async def test_block_mot_set_outside_limits(mot_block):
382375
async def test_block_failing_write(timeout_is_error):
383376
block = await _block_with_write_config(BlockWriteConfig(timeout_is_error=timeout_is_error))
384377

385-
get_mock_put(block.setpoint).side_effect = aio_timeout_error
378+
get_mock_put(block.setpoint).side_effect = TimeoutError
386379

387-
with pytest.raises(aio_timeout_error) if timeout_is_error else nullcontext():
380+
with pytest.raises(TimeoutError) if timeout_is_error else nullcontext():
388381
await block.set(1)
389382

390383

391384
async def test_block_failing_write_with_default_write_config(writable_block):
392-
get_mock_put(writable_block.setpoint).side_effect = aio_timeout_error
393-
with pytest.raises(aio_timeout_error):
385+
get_mock_put(writable_block.setpoint).side_effect = TimeoutError
386+
with pytest.raises(TimeoutError):
394387
await writable_block.set(1)

0 commit comments

Comments
 (0)