diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index bfab15978..5624ec0dc 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -68,6 +68,7 @@ jobs: pip install . - name: Run Mypy run: mypy qcodes_contrib_drivers + if: matrix.python-version != '3.7' - name: Run tests run: | pytest --cov=qcodes_contrib_drivers --cov-report xml --cov-config=setup.cfg qcodes_contrib_drivers diff --git a/qcodes_contrib_drivers/drivers/NationalInstruments/Switch.py b/qcodes_contrib_drivers/drivers/NationalInstruments/Switch.py index 4cdc4449f..500ed8126 100644 --- a/qcodes_contrib_drivers/drivers/NationalInstruments/Switch.py +++ b/qcodes_contrib_drivers/drivers/NationalInstruments/Switch.py @@ -1,9 +1,8 @@ import logging -from typing import Optional, Dict, List, cast +from typing import Dict, List, Optional, cast -from qcodes import Instrument, InstrumentChannel, ChannelList - -from niswitch import Session, PathCapability +from niswitch import PathCapability, Session +from qcodes import ChannelList, Instrument, InstrumentChannel logger = logging.getLogger(__name__) @@ -159,5 +158,5 @@ def disconnect_from_all(self) -> None: Disconnect this channel from all channels it is connected to. """ while len(self.connection_list) > 0: - ch = cast(InstrumentChannel, self.connection_list[0]) + ch = self.connection_list[0] self.disconnect_from(ch) diff --git a/qcodes_contrib_drivers/drivers/QDevil/QDAC2.py b/qcodes_contrib_drivers/drivers/QDevil/QDAC2.py index 3e0912286..6e577706b 100644 --- a/qcodes_contrib_drivers/drivers/QDevil/QDAC2.py +++ b/qcodes_contrib_drivers/drivers/QDevil/QDAC2.py @@ -1554,14 +1554,14 @@ def __exit__(self, exc_type, exc_val, exc_tb): # Let Arrangement take care of freeing triggers return False - def actual_values_V(self, gate: str) -> Sequence[float]: + def actual_values_V(self, gate: str) -> np.ndarray: """The corrected values that would actually be sent to the gate Args: gate (str): Name of gate Returns: - Sequence[float]: Corrected voltages + np.ndarray: Corrected voltages """ index = self._arrangement._gate_index(gate) return self._sweep[:, index] diff --git a/qcodes_contrib_drivers/drivers/Spectrum/M4i.py b/qcodes_contrib_drivers/drivers/Spectrum/M4i.py index a4c590854..8c0810060 100644 --- a/qcodes_contrib_drivers/drivers/Spectrum/M4i.py +++ b/qcodes_contrib_drivers/drivers/Spectrum/M4i.py @@ -988,7 +988,9 @@ def _transfer_buffer_numpy(self, memsize: int, numch: int, bytes_per_sample=2) - raise Exception(f'Error transferring data: {_errormsg_dict[res]} (0x{res:04x})') # convert buffer to numpy array - output = np.frombuffer(data_buffer, dtype=sample_ctype) + # this does not typecheck with numpy 1.22 should be updated + # by someone with access to test on the real data. + output = np.frombuffer(data_buffer, dtype=sample_ctype) # type: ignore[call-overload] return output diff --git a/qcodes_contrib_drivers/tests/QDevil/test_sim_qdac2_init.py b/qcodes_contrib_drivers/tests/QDevil/test_sim_qdac2_init.py index e2a3817c9..2a5470d0e 100644 --- a/qcodes_contrib_drivers/tests/QDevil/test_sim_qdac2_init.py +++ b/qcodes_contrib_drivers/tests/QDevil/test_sim_qdac2_init.py @@ -13,8 +13,11 @@ def test_refuse_wrong_model(): # ----------------------------------------------------------------------- assert 'Unknown model' in repr(error) # Circumvent Instrument not handling exceptions in constructor. - Instrument._all_instruments.pop(wrong_instrument) - + # In qcodes < 0.32 + try: + Instrument._all_instruments.pop(wrong_instrument) + except KeyError: + pass def test_refuse_incompatible_firmware(): # ----------------------------------------------------------------------- @@ -23,4 +26,8 @@ def test_refuse_incompatible_firmware(): # ----------------------------------------------------------------------- assert 'Incompatible firmware' in repr(error) # Circumvent Instrument not handling exceptions in constructor. - Instrument._all_instruments.pop('qdac') + # In qcodes < 0.32 + try: + Instrument._all_instruments.pop('qdac') + except KeyError: + pass diff --git a/setup.cfg b/setup.cfg index 56849a89c..326ffea44 100644 --- a/setup.cfg +++ b/setup.cfg @@ -46,6 +46,7 @@ show_column_numbers = True warn_unused_ignores = True warn_unused_configs = True warn_redundant_casts = True +show_error_codes = True [mypy-qcodes_contrib_drivers._version] ignore_errors = True