Skip to content

Commit 9fa2192

Browse files
committed
Fix mypy type checking
1 parent 6dffc02 commit 9fa2192

6 files changed

Lines changed: 20 additions & 6 deletions

File tree

src/qcodes/instrument/channel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def parent(self) -> _TIB_co:
8787
return self._parent
8888

8989
@property
90-
def root_instrument(self) -> Instrument:
90+
def root_instrument(self) -> Instrument: # type: ignore[override]
9191
# the root instrument is the top level parent of this module, we need to
9292
# go up the parent hierarchy until we find an object that returns itself as the parent, this should be the root instrument. We also
9393
# this is required to be an Instrument.

src/qcodes/instrument_drivers/Keysight/Infiniium.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,10 @@ def __init__(
526526
)
527527

528528
@property
529-
def root_instrument(self) -> "KeysightInfiniium":
529+
def root_instrument(self) -> "KeysightInfiniium": # type: ignore[override]
530+
# ideally this should be a generic type parameter but
531+
# for now we override it here. This requies a mypy ignore
532+
# because the return type is more specific than the parent class.
530533
root_instrument = super().root_instrument
531534
assert isinstance(root_instrument, KeysightInfiniium)
532535
return root_instrument

src/qcodes/instrument_drivers/Keysight/KtMAwg.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ def __init__(
142142
"""Parameter digital_gain"""
143143

144144
@property
145-
def root_instrument(self) -> "KeysightM9336A":
145+
def root_instrument(self) -> "KeysightM9336A": # type: ignore[override]
146+
# ideally this should be a generic type parameter but
147+
# for now we override it here. This requies a mypy ignore
148+
# because the return type is more specific than the parent class.
146149
root_instrument = super().root_instrument
147150
assert isinstance(root_instrument, KeysightM9336A)
148151
return root_instrument

src/qcodes/instrument_drivers/Keysight/N52xx.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,10 @@ def __init__(
300300
"""Parameter polar"""
301301

302302
@property
303-
def root_instrument(self) -> "KeysightPNABase":
303+
def root_instrument(self) -> "KeysightPNABase": # type: ignore[override]
304+
# ideally this should be a generic type parameter but
305+
# for now we override it here. This requies a mypy ignore
306+
# because the return type is more specific than the parent class.
304307
root_instrument = super().root_instrument
305308
assert isinstance(root_instrument, KeysightPNABase)
306309
return root_instrument

src/qcodes/instrument_drivers/tektronix/DPO7200xx.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,10 @@ def __init__(
355355
"""Parameter trace"""
356356

357357
@property
358-
def root_instrument(self) -> "TektronixDPO7000xx":
358+
def root_instrument(self) -> "TektronixDPO7000xx": # type: ignore[override]
359+
# ideally this should be a generic type parameter but
360+
# for now we override it here. This requies a mypy ignore
361+
# because the return type is more specific than the parent class.
359362
root_instrument = super().root_instrument
360363
assert isinstance(root_instrument, TektronixDPO7000xx)
361364
return root_instrument

src/qcodes/monitor/monitor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646

4747
from websockets.asyncio.server import ServerConnection
4848

49+
from qcodes.instrument import InstrumentBase
50+
4951
WEBSOCKET_PORT = 5678
5052
SERVER_PORT = 3000
5153

@@ -78,7 +80,7 @@ def _get_metadata(
7880

7981
# find the base instrument that this parameter belongs to
8082
if use_root_instrument:
81-
baseinst = parameter.root_instrument
83+
baseinst: InstrumentBase | None = parameter.root_instrument
8284
else:
8385
baseinst = parameter.instrument
8486
if baseinst is None:

0 commit comments

Comments
 (0)