Skip to content

Commit 63ee5d2

Browse files
committed
Fix typechecking of tests
1 parent 482a1fa commit 63ee5d2

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

tests/parameter/test_combined_parameter_extended.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ def test_combine_creates_combined_parameter(
3131
def test_combine_with_label_and_unit(self, two_params: list[Parameter]) -> None:
3232
"""combine() passes label and unit through."""
3333
cp = combine(*two_params, name="xy", label="X and Y", unit="V")
34-
assert cp.parameter.label == "X and Y"
35-
assert cp.parameter.unit == "V"
34+
# cp.parameter is a parameter like object but these attributes are dynamically added
35+
assert cp.parameter.label == "X and Y" # pyright: ignore[reportFunctionMemberAccess]
36+
assert cp.parameter.unit == "V" # pyright: ignore[reportFunctionMemberAccess]
3637

3738
def test_combine_with_aggregator(self, two_params: list[Parameter]) -> None:
3839
"""combine() passes aggregator through."""
@@ -108,15 +109,17 @@ def test_units_deprecated(
108109
with caplog.at_level(logging.WARNING):
109110
cp = CombinedParameter(two_params, name="xy", units="mV")
110111
assert any("`units` is deprecated" in msg for msg in caplog.messages)
111-
assert cp.parameter.unit == "mV"
112+
# cp.parameter is a parameter like object but these attributes are dynamically added
113+
assert cp.parameter.unit == "mV" # pyright: ignore[reportFunctionMemberAccess]
112114

113115
def test_units_deprecated_unit_takes_precedence(
114116
self, two_params: list[Parameter], caplog: pytest.LogCaptureFixture
115117
) -> None:
116118
"""When both unit and units are given, unit takes precedence."""
117119
with caplog.at_level(logging.WARNING):
118120
cp = CombinedParameter(two_params, name="xy", unit="V", units="mV")
119-
assert cp.parameter.unit == "V"
121+
# cp.parameter is a parameter like object but these attributes are dynamically added
122+
assert cp.parameter.unit == "V" # pyright: ignore[reportFunctionMemberAccess]
120123

121124
def test_invalid_name_raises(self, two_params: list[Parameter]) -> None:
122125
"""Invalid parameter name raises ValueError."""

tests/test_channel_extended.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class OtherChannel(InstrumentChannel):
178178
ct1 = ch_instr.channels
179179
ct2 = ChannelTuple(ch_instr, "other", OtherChannel)
180180
with pytest.raises(TypeError, match="same type"):
181-
ct1 + ct2
181+
_ = ct1 + ct2
182182

183183

184184
@pytest.mark.serial
@@ -190,7 +190,7 @@ def test_channel_tuple_add_different_parent() -> None:
190190
ct1 = instr1.channels[0:1]
191191
ct2 = instr2.channels[0:1]
192192
with pytest.raises(ValueError, match="same parent"):
193-
ct1 + ct2
193+
_ = ct1 + ct2
194194
finally:
195195
instr1.close()
196196
instr2.close()

tests/test_instrument_extended.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ def test_ask_wraps_exception() -> None:
116116
@pytest.mark.serial
117117
def test_close_all() -> None:
118118
"""close_all should remove all registered instruments."""
119-
DummyInstrument(name="closeall1", gates=["g1"])
120-
DummyInstrument(name="closeall2", gates=["g2"])
119+
_ = DummyInstrument(name="closeall1", gates=["g1"])
120+
_ = DummyInstrument(name="closeall2", gates=["g2"])
121121

122122
assert Instrument.exist("closeall1")
123123
assert Instrument.exist("closeall2")

0 commit comments

Comments
 (0)