Skip to content

Commit

Permalink
Add types to remaining drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshnielsen committed May 18, 2024
1 parent ae551fc commit c9f470e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 18 deletions.
15 changes: 11 additions & 4 deletions src/qcodes/instrument_drivers/weinschel/Weinschel_8320.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from typing import Any
from typing import TYPE_CHECKING

import numpy as np

from qcodes import validators as vals
from qcodes.instrument import VisaInstrument
from qcodes.instrument import VisaInstrument, VisaInstrumentKWArgs
from qcodes.parameters import Parameter

if TYPE_CHECKING:
from typing_extensions import Unpack


class Weinschel8320(VisaInstrument):
"""
Expand All @@ -14,8 +17,12 @@ class Weinschel8320(VisaInstrument):
Weinschel is formerly known as Aeroflex/Weinschel
"""

def __init__(self, name: str, address: str, **kwargs: Any):
super().__init__(name, address, terminator='\r', **kwargs)
default_terminator = "\r"

def __init__(
self, name: str, address: str, **kwargs: "Unpack[VisaInstrumentKWArgs]"
):
super().__init__(name, address, **kwargs)

Check warning on line 25 in src/qcodes/instrument_drivers/weinschel/Weinschel_8320.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/instrument_drivers/weinschel/Weinschel_8320.py#L25

Added line #L25 was not covered by tests
self.attenuation = Parameter(
"attenuation",
unit="dB",
Expand Down
43 changes: 33 additions & 10 deletions src/qcodes/instrument_drivers/yokogawa/GS200.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@
"""

from functools import partial
from typing import Any, Literal, Optional, Union

from qcodes.instrument import InstrumentChannel, VisaInstrument
from typing import TYPE_CHECKING, Literal, Optional, Union

from qcodes.instrument import (
InstrumentBaseKWArgs,
InstrumentChannel,
VisaInstrument,
VisaInstrumentKWArgs,
)
from qcodes.parameters import DelegateParameter
from qcodes.validators import Bool, Enum, Ints, Numbers

if TYPE_CHECKING:
from typing_extensions import Unpack

ModeType = Literal["CURR", "VOLT"]


Expand Down Expand Up @@ -46,8 +54,14 @@ class GS200_Monitor(InstrumentChannel):
present
"""

def __init__(self, parent: "GS200", name: str, present: bool) -> None:
super().__init__(parent, name)
def __init__(
self,
parent: "GS200",
name: str,
present: bool,
**kwargs: "Unpack[InstrumentBaseKWArgs]",
) -> None:
super().__init__(parent, name, **kwargs)

Check warning on line 64 in src/qcodes/instrument_drivers/yokogawa/GS200.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/instrument_drivers/yokogawa/GS200.py#L64

Added line #L64 was not covered by tests

self.present = present

Expand Down Expand Up @@ -186,8 +200,13 @@ def update_measurement_enabled(self, unit: ModeType, output_range: float) -> Non
class GS200Program(InstrumentChannel):
""" """

def __init__(self, parent: "GS200", name: str) -> None:
super().__init__(parent, name)
def __init__(
self,
parent: "GS200",
name: str,
**kwargs: "Unpack[InstrumentBaseKWArgs]",
) -> None:
super().__init__(parent, name, **kwargs)

Check warning on line 209 in src/qcodes/instrument_drivers/yokogawa/GS200.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/instrument_drivers/yokogawa/GS200.py#L209

Added line #L209 was not covered by tests
self._repeat = 1
self._file_name = None

Expand Down Expand Up @@ -266,13 +285,17 @@ class GS200(VisaInstrument):
name: What this instrument is called locally.
address: The GPIB or USB address of this instrument
kwargs: kwargs to be passed to VisaInstrument class
terminator: read terminator for reads/writes to the instrument.
"""

default_terminator = "\n"

def __init__(
self, name: str, address: str, terminator: str = "\n", **kwargs: Any
self,
name: str,
address: str,
**kwargs: "Unpack[VisaInstrumentKWArgs]",
) -> None:
super().__init__(name, address, terminator=terminator, **kwargs)
super().__init__(name, address, **kwargs)

Check warning on line 298 in src/qcodes/instrument_drivers/yokogawa/GS200.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/instrument_drivers/yokogawa/GS200.py#L298

Added line #L298 was not covered by tests

self.add_parameter(
"output",
Expand Down
20 changes: 16 additions & 4 deletions src/qcodes/instrument_drivers/yokogawa/Yokogawa_GS200.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import TYPE_CHECKING, Literal, Optional, Union

from qcodes.instrument import (
InstrumentBaseKWArgs,
InstrumentChannel,
VisaInstrument,
VisaInstrumentKWArgs,
Expand Down Expand Up @@ -48,8 +49,14 @@ class YokogawaGS200Monitor(InstrumentChannel):
present
"""

def __init__(self, parent: "YokogawaGS200", name: str, present: bool) -> None:
super().__init__(parent, name)
def __init__(
self,
parent: "YokogawaGS200",
name: str,
present: bool,
**kwargs: "Unpack[InstrumentBaseKWArgs]",
) -> None:
super().__init__(parent, name, **kwargs)

self.present = present

Expand Down Expand Up @@ -188,8 +195,13 @@ def update_measurement_enabled(self, unit: ModeType, output_range: float) -> Non
class YokogawaGS200Program(InstrumentChannel):
""" """

def __init__(self, parent: "YokogawaGS200", name: str) -> None:
super().__init__(parent, name)
def __init__(
self,
parent: "YokogawaGS200",
name: str,
**kwargs: "Unpack[InstrumentBaseKWArgs]",
) -> None:
super().__init__(parent, name, **kwargs)
self._repeat = 1
self._file_name = None

Expand Down

0 comments on commit c9f470e

Please sign in to comment.