From 144c51bd990963cba44e3b2a591284d4ecf1bc4e Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Fri, 17 May 2024 11:31:49 +0200 Subject: [PATCH] use typed kwargs for remaining Keysight drivers --- .../Keysight/KeysightAgilent_33XXX.py | 38 ++++++++++++++---- .../Keysight/Keysight_B2962A.py | 34 +++++++++++++--- .../Keysight/Keysight_N5183B.py | 11 ++++- .../Keysight/Keysight_N5222B.py | 11 ++++- .../Keysight/Keysight_N5230C.py | 11 ++++- .../Keysight/Keysight_N5245A.py | 11 ++++- .../Keysight/Keysight_N6705B.py | 31 +++++++++++--- .../Keysight/Keysight_N9030B.py | 30 +++++++++++--- .../Keysight/Keysight_P9374A.py | 11 ++++- .../instrument_drivers/Keysight/KtM960x.py | 22 +++++----- .../instrument_drivers/Keysight/KtMAwg.py | 32 ++++++++++----- .../instrument_drivers/Keysight/N51x1.py | 20 ++++++++-- .../instrument_drivers/Keysight/N52xx.py | 40 +++++++++++++------ .../Keysight/keysight_34934a.py | 21 +++++++--- .../Keysight/keysight_b220x.py | 13 ++++-- .../Keysight/keysight_e4980a.py | 32 ++++++++++----- 16 files changed, 276 insertions(+), 92 deletions(-) diff --git a/src/qcodes/instrument_drivers/Keysight/KeysightAgilent_33XXX.py b/src/qcodes/instrument_drivers/Keysight/KeysightAgilent_33XXX.py index ec628305748..9bcaf6e6eed 100644 --- a/src/qcodes/instrument_drivers/Keysight/KeysightAgilent_33XXX.py +++ b/src/qcodes/instrument_drivers/Keysight/KeysightAgilent_33XXX.py @@ -1,12 +1,21 @@ import logging from functools import partial -from typing import Any, Union +from typing import TYPE_CHECKING, Union from qcodes import validators as vals -from qcodes.instrument import Instrument, InstrumentChannel, VisaInstrument +from qcodes.instrument import ( + Instrument, + InstrumentBaseKWArgs, + InstrumentChannel, + VisaInstrument, + VisaInstrumentKWArgs, +) from .private.error_handling import KeysightErrorQueueMixin +if TYPE_CHECKING: + from typing_extensions import Unpack + log = logging.getLogger(__name__) @@ -19,15 +28,23 @@ class Keysight33xxxOutputChannel(InstrumentChannel): """ Class to hold the output channel of a Keysight 33xxxx waveform generator. """ - def __init__(self, parent: Instrument, name: str, channum: int) -> None: + + def __init__( + self, + parent: Instrument, + name: str, + channum: int, + **kwargs: "Unpack[InstrumentBaseKWArgs]", + ) -> None: """ Args: parent: The instrument to which the channel is attached. name: The name of the channel channum: The number of the channel in question (1-2) + **kwargs: kwargs are forwarded to base class. """ - super().__init__(parent, name) + super().__init__(parent, name, **kwargs) def val_parser(parser: type, inputstring: str) -> Union[float,int]: """ @@ -288,8 +305,15 @@ class WaveformGenerator_33XXX(KeysightErrorQueueMixin, VisaInstrument): waveform generators """ - def __init__(self, name: str, address: str, - silent: bool = False, **kwargs: Any): + default_terminator = "\n" + + def __init__( + self, + name: str, + address: str, + silent: bool = False, + **kwargs: "Unpack[VisaInstrumentKWArgs]", + ): """ Args: name: The name of the instrument used internally @@ -299,7 +323,7 @@ def __init__(self, name: str, address: str, **kwargs: kwargs are forwarded to base class. """ - super().__init__(name, address, terminator='\n', **kwargs) + super().__init__(name, address, **kwargs) self.model = self.IDN()['model'] ####################################################################### diff --git a/src/qcodes/instrument_drivers/Keysight/Keysight_B2962A.py b/src/qcodes/instrument_drivers/Keysight/Keysight_B2962A.py index 8159bc46478..a733274fa38 100644 --- a/src/qcodes/instrument_drivers/Keysight/Keysight_B2962A.py +++ b/src/qcodes/instrument_drivers/Keysight/Keysight_B2962A.py @@ -1,18 +1,35 @@ -from typing import Any, Optional +from typing import TYPE_CHECKING, Optional -from qcodes.instrument import Instrument, InstrumentChannel, VisaInstrument +from qcodes.instrument import ( + Instrument, + InstrumentBaseKWArgs, + InstrumentChannel, + VisaInstrument, + VisaInstrumentKWArgs, +) + +if TYPE_CHECKING: + from typing_extensions import Unpack class KeysightB2962AChannel(InstrumentChannel): """ """ - def __init__(self, parent: Instrument, name: str, chan: int) -> None: + + def __init__( + self, + parent: Instrument, + name: str, + chan: int, + **kwargs: "Unpack[InstrumentBaseKWArgs]", + ) -> None: """ Args: parent: The instrument to which the channel is attached. name: The name of the channel chan: The number of the channel in question (1-2) + **kwargs: Forwarded to base class. """ # Sanity Check inputs if name not in ["ch1", "ch2"]: @@ -20,7 +37,7 @@ def __init__(self, parent: Instrument, name: str, chan: int) -> None: if chan not in [1, 2]: raise ValueError(f"Invalid Channel: {chan}, expected '1' or '2'") - super().__init__(parent, name) + super().__init__(parent, name, **kwargs) self.add_parameter('source_voltage', label=f"Channel {chan} Voltage", @@ -96,8 +113,13 @@ class KeysightB2962A(VisaInstrument): - Similar drivers have special handlers to map return values of 9.9e+37 to inf, is this needed? """ - def __init__(self, name: str, address: str, **kwargs: Any): - super().__init__(name, address, terminator='\n', **kwargs) + + default_terminator = "\n" + + def __init__( + self, name: str, address: str, **kwargs: "Unpack[VisaInstrumentKWArgs]" + ): + super().__init__(name, address, **kwargs) # The B2962A supports two channels for ch_num in [1, 2]: diff --git a/src/qcodes/instrument_drivers/Keysight/Keysight_N5183B.py b/src/qcodes/instrument_drivers/Keysight/Keysight_N5183B.py index e17896bd3ac..7ab9523d316 100644 --- a/src/qcodes/instrument_drivers/Keysight/Keysight_N5183B.py +++ b/src/qcodes/instrument_drivers/Keysight/Keysight_N5183B.py @@ -1,10 +1,17 @@ -from typing import Any +from typing import TYPE_CHECKING from qcodes.instrument_drivers.Keysight.N51x1 import N51x1 +if TYPE_CHECKING: + from typing_extensions import Unpack + + from qcodes.instrument import VisaInstrumentKWArgs + class KeysightN5183B(N51x1): - def __init__(self, name: str, address: str, **kwargs: Any): + def __init__( + self, name: str, address: str, **kwargs: "Unpack[VisaInstrumentKWArgs]" + ): super().__init__(name, address, min_power=-20, max_power=19, **kwargs) diff --git a/src/qcodes/instrument_drivers/Keysight/Keysight_N5222B.py b/src/qcodes/instrument_drivers/Keysight/Keysight_N5222B.py index f97fd8c4061..12219246e57 100644 --- a/src/qcodes/instrument_drivers/Keysight/Keysight_N5222B.py +++ b/src/qcodes/instrument_drivers/Keysight/Keysight_N5222B.py @@ -1,10 +1,17 @@ -from typing import Any +from typing import TYPE_CHECKING from . import N52xx +if TYPE_CHECKING: + from typing_extensions import Unpack + + from qcodes.instrument import VisaInstrumentKWArgs + class KeysightN5222B(N52xx.PNABase): - def __init__(self, name: str, address: str, **kwargs: Any): + def __init__( + self, name: str, address: str, **kwargs: "Unpack[VisaInstrumentKWArgs]" + ): """Driver for Keysight PNA N5222B.""" super().__init__( name, diff --git a/src/qcodes/instrument_drivers/Keysight/Keysight_N5230C.py b/src/qcodes/instrument_drivers/Keysight/Keysight_N5230C.py index 7a752ac263f..e9ca7764236 100644 --- a/src/qcodes/instrument_drivers/Keysight/Keysight_N5230C.py +++ b/src/qcodes/instrument_drivers/Keysight/Keysight_N5230C.py @@ -1,10 +1,17 @@ -from typing import Any +from typing import TYPE_CHECKING from . import N52xx +if TYPE_CHECKING: + from typing_extensions import Unpack + + from qcodes.instrument import VisaInstrumentKWArgs + class KeysightN5230C(N52xx.PNABase): - def __init__(self, name: str, address: str, **kwargs: Any): + def __init__( + self, name: str, address: str, **kwargs: "Unpack[VisaInstrumentKWArgs]" + ): super().__init__( name, address, diff --git a/src/qcodes/instrument_drivers/Keysight/Keysight_N5245A.py b/src/qcodes/instrument_drivers/Keysight/Keysight_N5245A.py index 2b21c406dee..f59a9da91f4 100644 --- a/src/qcodes/instrument_drivers/Keysight/Keysight_N5245A.py +++ b/src/qcodes/instrument_drivers/Keysight/Keysight_N5245A.py @@ -1,10 +1,17 @@ -from typing import Any +from typing import TYPE_CHECKING from . import N52xx +if TYPE_CHECKING: + from typing_extensions import Unpack + + from qcodes.instrument import VisaInstrumentKWArgs + class KeysightN5245A(N52xx.PNAxBase): - def __init__(self, name: str, address: str, **kwargs: Any): + def __init__( + self, name: str, address: str, **kwargs: "Unpack[VisaInstrumentKWArgs]" + ): super().__init__( name, address, diff --git a/src/qcodes/instrument_drivers/Keysight/Keysight_N6705B.py b/src/qcodes/instrument_drivers/Keysight/Keysight_N6705B.py index 667f9420eae..b6fa775787c 100644 --- a/src/qcodes/instrument_drivers/Keysight/Keysight_N6705B.py +++ b/src/qcodes/instrument_drivers/Keysight/Keysight_N6705B.py @@ -1,14 +1,29 @@ -from typing import Any, Optional +from typing import TYPE_CHECKING, Optional -from qcodes.instrument import Instrument, InstrumentChannel, VisaInstrument +from qcodes.instrument import ( + Instrument, + InstrumentBaseKWArgs, + InstrumentChannel, + VisaInstrument, + VisaInstrumentKWArgs, +) + +if TYPE_CHECKING: + from typing_extensions import Unpack class KeysightN6705BChannel(InstrumentChannel): - def __init__(self, parent: Instrument, name: str, chan: int) -> None: + def __init__( + self, + parent: Instrument, + name: str, + chan: int, + **kwargs: "Unpack[InstrumentBaseKWArgs]", + ) -> None: if chan not in [1, 2, 3, 4]: raise ValueError('Invalid channel specified') - super().__init__(parent, name) + super().__init__(parent, name, **kwargs) self.add_parameter('source_voltage', label=f"Channel {chan} Voltage", @@ -62,8 +77,12 @@ def __init__(self, parent: Instrument, name: str, chan: int) -> None: class KeysightN6705B(VisaInstrument): - def __init__(self, name: str, address: str, **kwargs: Any) -> None: - super().__init__(name, address, terminator="\n", **kwargs) + default_terminator = "\n" + + def __init__( + self, name: str, address: str, **kwargs: "Unpack[VisaInstrumentKWArgs]" + ) -> None: + super().__init__(name, address, **kwargs) self.channels: list[KeysightN6705BChannel] = [] for ch_num in [1, 2, 3, 4]: ch_name = f"ch{ch_num}" diff --git a/src/qcodes/instrument_drivers/Keysight/Keysight_N9030B.py b/src/qcodes/instrument_drivers/Keysight/Keysight_N9030B.py index ade26b536fc..ee06a76cd32 100644 --- a/src/qcodes/instrument_drivers/Keysight/Keysight_N9030B.py +++ b/src/qcodes/instrument_drivers/Keysight/Keysight_N9030B.py @@ -1,10 +1,15 @@ from __future__ import annotations -from typing import Any, Callable +from typing import TYPE_CHECKING, Any, Callable import numpy as np -from qcodes.instrument import InstrumentChannel, VisaInstrument +from qcodes.instrument import ( + InstrumentBaseKWArgs, + InstrumentChannel, + VisaInstrument, + VisaInstrumentKWArgs, +) from qcodes.parameters import ( Parameter, ParameterWithSetpoints, @@ -13,6 +18,9 @@ ) from qcodes.validators import Arrays, Bool, Enum, Ints, Numbers +if TYPE_CHECKING: + from typing_extensions import Unpack + class FrequencyAxis(Parameter): def __init__( @@ -73,7 +81,7 @@ def __init__( name: str, *arg: Any, additional_wait: int = 1, - **kwargs: Any, + **kwargs: Unpack[InstrumentBaseKWArgs], ): super().__init__(parent, name, *arg, **kwargs) @@ -411,7 +419,13 @@ class KeysightN9030BPhaseNoiseMode(InstrumentChannel): Phase Noise Mode for Keysight N9030B instrument. """ - def __init__(self, parent: KeysightN9030B, name: str, *arg: Any, **kwargs: Any): + def __init__( + self, + parent: KeysightN9030B, + name: str, + *arg: Any, + **kwargs: Unpack[InstrumentBaseKWArgs], + ): super().__init__(parent, name, *arg, **kwargs) self._min_freq = 1 @@ -611,8 +625,12 @@ class KeysightN9030B(VisaInstrument): address """ - def __init__(self, name: str, address: str, **kwargs: Any) -> None: - super().__init__(name, address, terminator="\n", **kwargs) + default_terminator = "\n" + + def __init__( + self, name: str, address: str, **kwargs: Unpack[VisaInstrumentKWArgs] + ) -> None: + super().__init__(name, address, **kwargs) self._min_freq: float self._max_freq: float diff --git a/src/qcodes/instrument_drivers/Keysight/Keysight_P9374A.py b/src/qcodes/instrument_drivers/Keysight/Keysight_P9374A.py index 87025cbc863..27164a968dc 100644 --- a/src/qcodes/instrument_drivers/Keysight/Keysight_P9374A.py +++ b/src/qcodes/instrument_drivers/Keysight/Keysight_P9374A.py @@ -1,12 +1,19 @@ -from typing import Any +from typing import TYPE_CHECKING from . import N52xx +if TYPE_CHECKING: + from typing_extensions import Unpack + + from qcodes.instrument import VisaInstrumentKWArgs + # This is not the same class of Keysight devices but seems to work well... class KeysightP9374A(N52xx.PNAxBase): - def __init__(self, name: str, address: str, **kwargs: Any): + def __init__( + self, name: str, address: str, **kwargs: "Unpack[VisaInstrumentKWArgs]" + ): super().__init__( name, address, diff --git a/src/qcodes/instrument_drivers/Keysight/KtM960x.py b/src/qcodes/instrument_drivers/Keysight/KtM960x.py index 044c381d0ce..c9c12bf28cd 100644 --- a/src/qcodes/instrument_drivers/Keysight/KtM960x.py +++ b/src/qcodes/instrument_drivers/Keysight/KtM960x.py @@ -1,9 +1,9 @@ import ctypes from functools import partial -from typing import Any, Optional +from typing import TYPE_CHECKING, Optional import qcodes.validators as vals -from qcodes.instrument import Instrument +from qcodes.instrument import Instrument, InstrumentBaseKWArgs from qcodes.parameters import ( MultiParameter, ParamRawDataType, @@ -12,6 +12,9 @@ from .KtM960xDefs import * # noqa F403 +if TYPE_CHECKING: + from typing_extensions import Unpack + class Measure(MultiParameter): def __init__(self, name: str, instrument: "KeysightM960x") -> None: @@ -40,13 +43,14 @@ class KeysightM960x(Instrument): _default_buf_size = 256 - def __init__(self, - name: str, - address: str, - options: str = "", - dll_path: str = r"C:\Program Files\IVI " - r"Foundation\IVI\Bin\KtM960x_64.dll", - **kwargs: Any) -> None: + def __init__( + self, + name: str, + address: str, + options: str = "", + dll_path: str = r"C:\Program Files\IVI Foundation\IVI\Bin\KtM960x_64.dll", + **kwargs: "Unpack[InstrumentBaseKWArgs]", + ) -> None: super().__init__(name, **kwargs) self._address = bytes(address, "ascii") diff --git a/src/qcodes/instrument_drivers/Keysight/KtMAwg.py b/src/qcodes/instrument_drivers/Keysight/KtMAwg.py index 0459898752e..c16e13315ec 100644 --- a/src/qcodes/instrument_drivers/Keysight/KtMAwg.py +++ b/src/qcodes/instrument_drivers/Keysight/KtMAwg.py @@ -1,13 +1,16 @@ import ctypes from functools import partial -from typing import Any, Optional +from typing import TYPE_CHECKING, Optional -from qcodes.instrument import Instrument, InstrumentChannel +from qcodes.instrument import Instrument, InstrumentBaseKWArgs, InstrumentChannel from qcodes.parameters import create_on_off_val_mapping from qcodes.validators import Numbers from .KtMAwgDefs import * # noqa F403 +if TYPE_CHECKING: + from typing_extensions import Unpack + class KeysightM9336AAWGChannel(InstrumentChannel): """ @@ -16,14 +19,20 @@ class KeysightM9336AAWGChannel(InstrumentChannel): seperate waveforms. """ - def __init__(self, parent: "KeysightM9336A", name: str, chan: int) -> None: + def __init__( + self, + parent: "KeysightM9336A", + name: str, + chan: int, + **kwargs: "Unpack[InstrumentBaseKWArgs]", + ) -> None: # Sanity Check inputs if name not in ["ch1", "ch2", "ch3"]: raise ValueError(f"Invalid channel: {name}, expecting ch1:ch3") if chan not in [1, 2, 3]: raise ValueError(f"Invalid channel: {chan}, expecting ch1:ch3") - super().__init__(parent, name) + super().__init__(parent, name, **kwargs) self._channel = ctypes.create_string_buffer( f"Channel{chan}".encode("ascii") ) @@ -225,13 +234,14 @@ class KeysightM9336A(Instrument): """ _default_buf_size = 256 - def __init__(self, - name: str, - address: str, - options: str = "", - dll_path: str = r"C:\Program Files\IVI " - r"Foundation\IVI\Bin\KtMAwg_64.dll", - **kwargs: Any) -> None: + def __init__( + self, + name: str, + address: str, + options: str = "", + dll_path: str = r"C:\Program Files\IVI Foundation\IVI\Bin\KtMAwg_64.dll", + **kwargs: "Unpack[InstrumentBaseKWArgs]", + ) -> None: super().__init__(name, **kwargs) self._address = bytes(address, "ascii") diff --git a/src/qcodes/instrument_drivers/Keysight/N51x1.py b/src/qcodes/instrument_drivers/Keysight/N51x1.py index 5d1fbda2d0a..0cd5000b63b 100644 --- a/src/qcodes/instrument_drivers/Keysight/N51x1.py +++ b/src/qcodes/instrument_drivers/Keysight/N51x1.py @@ -1,9 +1,12 @@ -from typing import Any, Optional +from typing import TYPE_CHECKING, Optional -from qcodes.instrument import VisaInstrument +from qcodes.instrument import VisaInstrument, VisaInstrumentKWArgs from qcodes.parameters import create_on_off_val_mapping from qcodes.validators import Numbers +if TYPE_CHECKING: + from typing_extensions import Unpack + class N51x1(VisaInstrument): """ @@ -11,8 +14,17 @@ class N51x1(VisaInstrument): It has been tested with N5171B, N5181A, N5173B, N5183B """ - def __init__(self, name: str, address: str, min_power: int = -144, max_power: int = 19, **kwargs: Any): - super().__init__(name, address, terminator='\n', **kwargs) + default_terminator = "\n" + + def __init__( + self, + name: str, + address: str, + min_power: int = -144, + max_power: int = 19, + **kwargs: "Unpack[VisaInstrumentKWArgs]", + ): + super().__init__(name, address, **kwargs) self._options = self.ask("*OPT?") # Determine installed frequency option diff --git a/src/qcodes/instrument_drivers/Keysight/N52xx.py b/src/qcodes/instrument_drivers/Keysight/N52xx.py index 8b6547b6e15..7f5a57594b5 100644 --- a/src/qcodes/instrument_drivers/Keysight/N52xx.py +++ b/src/qcodes/instrument_drivers/Keysight/N52xx.py @@ -5,7 +5,13 @@ import numpy as np from pyvisa import constants, errors -from qcodes.instrument import ChannelList, InstrumentChannel, VisaInstrument +from qcodes.instrument import ( + ChannelList, + InstrumentBaseKWArgs, + InstrumentChannel, + VisaInstrument, + VisaInstrumentKWArgs, +) from qcodes.parameters import ( Parameter, ParameterBase, @@ -17,6 +23,8 @@ if TYPE_CHECKING: from collections.abc import Sequence + from typing_extensions import Unpack + class PNAAxisParameter(Parameter): def __init__( @@ -142,7 +150,7 @@ def __init__( port: int, min_power: Union[int, float], max_power: Union[int, float], - **kwargs: Any, + **kwargs: "Unpack[InstrumentBaseKWArgs]", ) -> None: super().__init__(parent, name, **kwargs) @@ -185,7 +193,7 @@ def __init__( name: str, trace_name: str, trace_num: int, - **kwargs: Any, + **kwargs: "Unpack[InstrumentBaseKWArgs]", ) -> None: super().__init__(parent, name, **kwargs) self.trace_name = trace_name @@ -384,16 +392,22 @@ class PNABase(VisaInstrument): may have unexpected results. """ - def __init__(self, - name: str, - address: str, - # Set frequency ranges - min_freq: Union[int, float], max_freq: Union[int, float], - # Set power ranges - min_power: Union[int, float], max_power: Union[int, float], - nports: int, # Number of ports on the PNA - **kwargs: Any) -> None: - super().__init__(name, address, terminator='\n', **kwargs) + default_terminator = "\n" + + def __init__( + self, + name: str, + address: str, + # Set frequency ranges + min_freq: Union[int, float], + max_freq: Union[int, float], + # Set power ranges + min_power: Union[int, float], + max_power: Union[int, float], + nports: int, # Number of ports on the PNA + **kwargs: "Unpack[VisaInstrumentKWArgs]", + ) -> None: + super().__init__(name, address, **kwargs) self.min_freq = min_freq self.max_freq = max_freq diff --git a/src/qcodes/instrument_drivers/Keysight/keysight_34934a.py b/src/qcodes/instrument_drivers/Keysight/keysight_34934a.py index 6249c5765dc..cfede2ef0e7 100644 --- a/src/qcodes/instrument_drivers/Keysight/keysight_34934a.py +++ b/src/qcodes/instrument_drivers/Keysight/keysight_34934a.py @@ -4,13 +4,19 @@ from qcodes import validators -from .keysight_34980a_submodules import KeysightSwitchMatrixSubModule +from .keysight_34980a_submodules import Keysight34980ASwitchMatrixSubModule if TYPE_CHECKING: - from qcodes.instrument import InstrumentChannel, VisaInstrument + from typing_extensions import Unpack + from qcodes.instrument import ( + InstrumentBaseKWArgs, + InstrumentChannel, + VisaInstrument, + ) -class Keysight34934A(KeysightSwitchMatrixSubModule): + +class Keysight34934A(Keysight34980ASwitchMatrixSubModule): """ Create an instance for module 34933A. @@ -20,10 +26,13 @@ class Keysight34934A(KeysightSwitchMatrixSubModule): slot: the slot the module is installed """ def __init__( - self, parent: Union["VisaInstrument", "InstrumentChannel"], name: str, slot: int + self, + parent: Union["VisaInstrument", "InstrumentChannel"], + name: str, + slot: int, + **kwargs: "Unpack[InstrumentBaseKWArgs]", ) -> None: - - super().__init__(parent, name, slot) + super().__init__(parent, name, slot, **kwargs) self.add_parameter( name="protection_mode", diff --git a/src/qcodes/instrument_drivers/Keysight/keysight_b220x.py b/src/qcodes/instrument_drivers/Keysight/keysight_b220x.py index c608c99cd29..7700c889222 100644 --- a/src/qcodes/instrument_drivers/Keysight/keysight_b220x.py +++ b/src/qcodes/instrument_drivers/Keysight/keysight_b220x.py @@ -3,12 +3,15 @@ from functools import wraps from typing import TYPE_CHECKING, Any, Callable, TypeVar -from qcodes.instrument import VisaInstrument +from qcodes.instrument import VisaInstrument, VisaInstrumentKWArgs from qcodes.validators import Enum, Ints, Lists, MultiType if TYPE_CHECKING: from collections.abc import Sequence + from typing_extensions import Unpack + + T = TypeVar('T') @@ -54,8 +57,12 @@ class KeysightB220X(VisaInstrument): _available_input_ports = Ints(1, 14) _available_output_ports = Ints(1, 48) - def __init__(self, name: str, address: str, **kwargs: Any): - super().__init__(name, address, terminator='\n', **kwargs) + default_terminator = "\n" + + def __init__( + self, name: str, address: str, **kwargs: "Unpack[VisaInstrumentKWArgs]" + ): + super().__init__(name, address, **kwargs) self._card = 0 diff --git a/src/qcodes/instrument_drivers/Keysight/keysight_e4980a.py b/src/qcodes/instrument_drivers/Keysight/keysight_e4980a.py index 427a7229289..6c55e49cb75 100644 --- a/src/qcodes/instrument_drivers/Keysight/keysight_e4980a.py +++ b/src/qcodes/instrument_drivers/Keysight/keysight_e4980a.py @@ -3,7 +3,12 @@ from packaging import version from pyvisa.errors import VisaIOError -from qcodes.instrument import InstrumentChannel, VisaInstrument +from qcodes.instrument import ( + InstrumentBaseKWArgs, + InstrumentChannel, + VisaInstrument, + VisaInstrumentKWArgs, +) from qcodes.parameters import ( Group, GroupParameter, @@ -18,6 +23,8 @@ if TYPE_CHECKING: from collections.abc import Sequence + from typing_extensions import Unpack + class KeysightE4980AMeasurementPair(MultiParameter): """ @@ -144,12 +151,14 @@ class KeysightE4980ACorrection(InstrumentChannel): """ Module for correction settings. """ + def __init__( - self, - parent: VisaInstrument, - name: str, + self, + parent: VisaInstrument, + name: str, + **kwargs: "Unpack[InstrumentBaseKWArgs]", ) -> None: - super().__init__(parent, name) + super().__init__(parent, name, **kwargs) self.add_parameter( "open", @@ -188,11 +197,12 @@ class KeysightE4980A(VisaInstrument): """ QCodes driver for E4980A Precision LCR Meter """ - def __init__(self, - name: str, - address: str, - terminator: str = '\n', - **kwargs: Any): + + default_terminator = "\n" + + def __init__( + self, name: str, address: str, **kwargs: "Unpack[VisaInstrumentKWArgs]" + ): """ Create an instance of the instrument. @@ -202,7 +212,7 @@ def __init__(self, terminator: Character to terminate messages with. **kwargs: kwargs are forwarded to base class. """ - super().__init__(name, address, terminator=terminator, **kwargs) + super().__init__(name, address, **kwargs) idn = self.IDN.get()