Skip to content

Commit

Permalink
fix some pyright errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap authored and ZohebShaikh committed Apr 30, 2024
1 parent ec616ca commit a06e169
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions tests/epics/demo/test_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,20 @@ async def test_mover_disconncted():
with pytest.raises(NotConnected):
async with DeviceCollector(timeout=0.1):
m = demo.Mover("ca://PRE:", name="mover")
assert m.name == "mover"
assert m.name == "mover"


async def test_sensor_disconnected(caplog):
caplog.set_level(10)
with pytest.raises(NotConnected):
async with DeviceCollector(timeout=0.1):
s = demo.Sensor("ca://PRE:", name="sensor")
assert s.name == "sensor"
logs = caplog.get_records("call")
assert len(logs) == 2

assert logs[0].message == ("signal ca://PRE:Value timed out")
assert logs[1].message == ("signal ca://PRE:Mode timed out")
assert s.name == "sensor"


async def test_read_sensor(sim_sensor: demo.Sensor):
Expand Down Expand Up @@ -261,7 +261,7 @@ async def test_dynamic_sensor_group_disconnected():
async with DeviceCollector(timeout=0.1):
sim_sensor_group_dynamic = demo.SensorGroup("SIM:SENSOR:")

assert sim_sensor_group_dynamic.name == "sim_sensor_group_dynamic"
assert sim_sensor_group_dynamic.name == "sim_sensor_group_dynamic"


async def test_dynamic_sensor_group_read_and_describe(
Expand Down
10 changes: 5 additions & 5 deletions tests/epics/demo/test_demo_ad_sim_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import bluesky.plan_stubs as bps
import pytest
from bluesky import RunEngine
from bluesky.run_engine import RunEngine
from bluesky.utils import new_uid

from ophyd_async.core import (
Expand Down Expand Up @@ -153,15 +153,15 @@ async def test_two_detectors_step(
info_a.root / info_a.resource_dir
)
file_name_a = await writer_a.hdf.file_name.get_value()
assert file_name_a.startswith(info_a.prefix)
assert file_name_a.endswith(info_a.suffix)
assert file_name_a.startswith(str(info_a.prefix))
assert file_name_a.endswith(str(info_a.suffix))

assert await writer_b.hdf.file_path.get_value() == str(
info_b.root / info_b.resource_dir
)
file_name_b = await writer_b.hdf.file_name.get_value()
assert file_name_b.startswith(info_b.prefix)
assert file_name_b.endswith(info_b.suffix)
assert file_name_b.startswith(str(info_b.prefix))
assert file_name_b.endswith(str(info_b.suffix))

_, descriptor, sra, sda, srb, sdb, event, _ = docs
assert descriptor["configuration"]["testa"]["data"]["testa-drv-acquire_time"] == 0.8
Expand Down
4 changes: 2 additions & 2 deletions tests/panda/test_panda_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ async def test_panda_gets_types_from_common_class(panda_pva, panda_t):
assert isinstance(panda.pulse[1], PulseBlock)

# others are just Devices
assert isinstance(panda.extra, Device)
assert isinstance(panda.extra, Device) # type: ignore[attr-defined]

# predefined signals get set up with the correct datatype
assert panda.pcap.active._backend.datatype is bool
Expand All @@ -154,7 +154,7 @@ async def test_panda_gets_types_from_common_class(panda_pva, panda_t):
assert panda.seq[1].table._backend.datatype is SeqTable

# others are given the None datatype
assert panda.pcap.newsignal._backend.datatype is None
assert panda.pcap.newsignal._backend.datatype is None # type: ignore[attr-defined]


async def test_panda_block_missing_signals(panda_pva, panda_t):
Expand Down
6 changes: 3 additions & 3 deletions tests/panda/test_panda_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from unittest.mock import patch

import pytest
from bluesky import RunEngine
from bluesky.run_engine import RunEngine

from ophyd_async.core import save_device
from ophyd_async.core.device import DeviceCollector
Expand All @@ -27,8 +27,8 @@ async def connect(self, sim: bool = False, timeout: float = DEFAULT_TIMEOUT):
await super().connect(sim, timeout)

async with DeviceCollector(sim=True):
sim_panda = Panda("PANDA")
sim_panda.phase_1_signal_units = epics_signal_rw(int, "")
sim_panda = PandA("PANDA:")
sim_panda.phase_1_signal_units = epics_signal_rw(int, "") # type: ignore[attr-defined]
assert sim_panda.name == "sim_panda"
yield sim_panda

Expand Down
8 changes: 4 additions & 4 deletions tests/panda/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ def test_from_arrays_inconsistent_lengths():
time2 = np.zeros(length)
time1 = np.zeros(length + 1)
with pytest.raises(ValueError, match="time1: has length 5 not 4"):
seq_table_from_arrays(time2=time2, time1=time1)
seq_table_from_arrays(time2=time2.astype(int), time1=time1.astype(int))
time1 = np.zeros(length - 1)
with pytest.raises(ValueError, match="time1: has length 3 not 4"):
seq_table_from_arrays(time2=time2, time1=time1)
seq_table_from_arrays(time2=time2.astype(int), time1=time1.astype(int))


def test_from_arrays_no_time():
Expand All @@ -22,10 +22,10 @@ def test_from_arrays_no_time():
seq_table_from_arrays() # type: ignore
time2 = np.zeros(0)
with pytest.raises(AssertionError, match="Length 0 not in range"):
seq_table_from_arrays(time2=time2)
seq_table_from_arrays(time2=time2.astype(int))


def test_from_arrays_too_long():
time2 = np.zeros(4097)
with pytest.raises(AssertionError, match="Length 4097 not in range"):
seq_table_from_arrays(time2=time2)
seq_table_from_arrays(time2=time2.astype(int))
8 changes: 4 additions & 4 deletions tests/panda/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ async def sim_writer(tmp_path, sim_panda) -> PandaHDFWriter:
async def test_get_capture_signals_gets_all_signals(sim_panda):
async with DeviceCollector(sim=True):
sim_panda.test_seq = Device("seq")
sim_panda.test_seq.seq1_capture = SignalR(backend=SimSignalBackend(str))
sim_panda.test_seq.seq2_capture = SignalR(backend=SimSignalBackend(str))
sim_panda.test_seq.seq1_capture = SignalR(backend=SimSignalBackend(str)) # type: ignore[attr-defined]
sim_panda.test_seq.seq2_capture = SignalR(backend=SimSignalBackend(str)) # type: ignore[attr-defined]
await asyncio.gather(
sim_panda.test_seq.connect(),
sim_panda.test_seq.seq1_capture.connect(),
sim_panda.test_seq.seq2_capture.connect(),
sim_panda.test_seq.seq1_capture.connect(), # type: ignore[attr-defined]
sim_panda.test_seq.seq2_capture.connect(), # type: ignore[attr-defined]
)
capture_signals = get_capture_signals(sim_panda)
expected_signals = [
Expand Down
4 changes: 2 additions & 2 deletions tests/sim/demo/test_sim_motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ async def test_move_sim_in_plan():
RE = RunEngine()

async with DeviceCollector():
m1 = SimMotor("M1", "sim_motor1")
m2 = SimMotor("M2", "sim_motor2")
m1 = SimMotor("M1")
m2 = SimMotor("M2")

my_plan = spiral_square([], m1, m2, 0, 0, 4, 4, 10, 10)

Expand Down

0 comments on commit a06e169

Please sign in to comment.