diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index c39e30d8aa0..c3a20fc97d8 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -86,7 +86,7 @@ jobs: if: ${{ !matrix.min-version }} - uses: jakebailey/pyright-action@03ab3c98073356eb56161009632b39fc2666321b # v2.0.1 with: - version: 1.1.339 + version: 1.1.349 if: ${{ !matrix.min-version }} - name: Run Mypy run: mypy -p qcodes diff --git a/pyproject.toml b/pyproject.toml index 6f94112b95d..bab927a8c7a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -210,7 +210,11 @@ reportDeprecated = true stubPath = "typings/stubs" # we would like to move this to at least standard # eventually. From 1.1.339 onwards standard is the default -typeCheckingMode = "basic" +# for now we enable all of standard except for +# incompatibleMethodOverride which we have a lot of +typeCheckingMode = "standard" +reportIncompatibleMethodOverride = false + [tool.pytest.ini_options] minversion = "7.2" diff --git a/src/qcodes/dataset/sqlite/queries.py b/src/qcodes/dataset/sqlite/queries.py index 15a4b4322db..cca73b63df2 100644 --- a/src/qcodes/dataset/sqlite/queries.py +++ b/src/qcodes/dataset/sqlite/queries.py @@ -242,9 +242,7 @@ def get_parameter_data_for_one_paramtree( # faster than transposing the data using np.array.transpose res_t = map(list, zip(*data)) - specs_and_data: zip_longest[ - tuple[ParamSpecBase | Sequence[Any], Sequence[Any]] - ] = zip_longest(paramspecs, res_t, fillvalue=()) + specs_and_data = zip_longest(paramspecs, res_t, fillvalue=()) for paramspec, column_data in specs_and_data: assert isinstance(paramspec, ParamSpecBase) diff --git a/src/qcodes/instrument_drivers/Keithley/_Keithley_2600.py b/src/qcodes/instrument_drivers/Keithley/_Keithley_2600.py index 809131a5a1f..af65f4ecf74 100644 --- a/src/qcodes/instrument_drivers/Keithley/_Keithley_2600.py +++ b/src/qcodes/instrument_drivers/Keithley/_Keithley_2600.py @@ -259,7 +259,7 @@ def _parse_response(data: str) -> tuple[float, Keithley2600MeasurementStatus]: status = _from_bits_tuple_to_status[ (status_bits[0], status_bits[1]) - ] # pyright: ignore[reportGeneralTypeIssues] + ] # pyright: ignore[reportArgumentType] return float(value), status diff --git a/src/qcodes/instrument_drivers/Keysight/private/Keysight_344xxA_submodules.py b/src/qcodes/instrument_drivers/Keysight/private/Keysight_344xxA_submodules.py index baaa811e346..3c3db692993 100644 --- a/src/qcodes/instrument_drivers/Keysight/private/Keysight_344xxA_submodules.py +++ b/src/qcodes/instrument_drivers/Keysight/private/Keysight_344xxA_submodules.py @@ -393,7 +393,7 @@ def _acquire_time_trace(self) -> np.ndarray: self.instrument.trigger.force() data = self.instrument.fetch() - return data # pyright: ignore[reportUnboundVariable] + return data # pyright: ignore[reportPossiblyUnboundVariable] def get_raw(self) -> np.ndarray: # pylint: disable=method-hidden diff --git a/src/qcodes/instrument_drivers/Minicircuits/USBHIDMixin.py b/src/qcodes/instrument_drivers/Minicircuits/USBHIDMixin.py index 1380d35ebd1..f5907ea054d 100644 --- a/src/qcodes/instrument_drivers/Minicircuits/USBHIDMixin.py +++ b/src/qcodes/instrument_drivers/Minicircuits/USBHIDMixin.py @@ -47,7 +47,7 @@ def __init__(self, name: str, instance_id: Optional[str] = None, **kwargs: Any): self._check_hid_import() - devs = hid.HidDeviceFilter( + devs = hid.HidDeviceFilter( # pyright: ignore[reportPossiblyUnboundVariable] product_id=self.product_id, vendor_id=self.vendor_id, instance_id=instance_id @@ -144,7 +144,7 @@ def enumerate_devices(cls) -> list[str]: """ cls._check_hid_import() - devs = hid.HidDeviceFilter( + devs = hid.HidDeviceFilter( # pyright: ignore[reportPossiblyUnboundVariable] porduct_id=cls.product_id, vendor_id=cls.vendor_id ).get_devices() diff --git a/src/qcodes/instrument_drivers/tektronix/AWG70000A.py b/src/qcodes/instrument_drivers/tektronix/AWG70000A.py index 6e87e92087b..bf63057c75c 100644 --- a/src/qcodes/instrument_drivers/tektronix/AWG70000A.py +++ b/src/qcodes/instrument_drivers/tektronix/AWG70000A.py @@ -493,15 +493,17 @@ def __init__( if add_channel_list: # pyright does not seem to understand # that this code can only run iff chanliss is created - chanlist.append(channel) # pyright: ignore[reportUnboundVariable] + chanlist.append( # pyright: ignore[reportPossiblyUnboundVariable] + channel + ) if add_channel_list: self.add_submodule( "channels", - chanlist.to_channel_tuple(), # pyright: ignore[reportUnboundVariable] + chanlist.to_channel_tuple(), # pyright: ignore[reportPossiblyUnboundVariable] ) - # Folder on the AWG where to files are uplaoded by default + # Folder on the AWG where to files are uploaded by default self.wfmxFileFolder = "\\Users\\OEM\\Documents" self.seqxFileFolder = "\\Users\\OEM\\Documents" diff --git a/src/qcodes/parameters/array_parameter.py b/src/qcodes/parameters/array_parameter.py index f9ae58f0881..013cc66d026 100644 --- a/src/qcodes/parameters/array_parameter.py +++ b/src/qcodes/parameters/array_parameter.py @@ -21,6 +21,25 @@ from qcodes.instrument import InstrumentBase +try: + from qcodes_loop.data.data_array import DataArray + + _SP_TYPES: tuple[type, ...] = ( + type(None), + DataArray, + collections.abc.Sequence, + collections.abc.Iterator, + np.ndarray, + ) +except ImportError: + _SP_TYPES = ( + type(None), + collections.abc.Sequence, + collections.abc.Iterator, + np.ndarray, + ) + + class ArrayParameter(ParameterBase): """ A gettable parameter that returns an array of values. @@ -154,23 +173,8 @@ def __init__( # require one setpoint per dimension of shape sp_shape = (len(shape),) - if has_loop: - sp_types: tuple[type, ...] = ( - nt, - DataArray, - collections.abc.Sequence, - collections.abc.Iterator, - np.ndarray, - ) - else: - sp_types = ( - nt, - collections.abc.Sequence, - collections.abc.Iterator, - np.ndarray, - ) if setpoints is not None and not is_sequence_of( - setpoints, sp_types, shape=sp_shape + setpoints, _SP_TYPES, shape=sp_shape ): raise ValueError("setpoints must be a tuple of arrays") if setpoint_names is not None and not is_sequence_of( diff --git a/src/qcodes/parameters/multi_parameter.py b/src/qcodes/parameters/multi_parameter.py index 232108f3f39..960db6fb3ca 100644 --- a/src/qcodes/parameters/multi_parameter.py +++ b/src/qcodes/parameters/multi_parameter.py @@ -6,20 +6,30 @@ import numpy as np -try: - from qcodes_loop.data.data_array import DataArray - - has_loop = True -except ImportError: - has_loop = False - - from .parameter_base import ParameterBase from .sequence_helpers import is_sequence_of if TYPE_CHECKING: from qcodes.instrument import InstrumentBase +try: + from qcodes_loop.data.data_array import DataArray + + _SP_TYPES: tuple[type, ...] = ( + type(None), + DataArray, + Sequence, + Iterator, + np.ndarray, + ) +except ImportError: + _SP_TYPES = ( + type(None), + Sequence, + Iterator, + np.ndarray, + ) + def _is_nested_sequence_or_none( obj: Any, @@ -180,22 +190,7 @@ def __init__( ) self.shapes = shapes - if has_loop: - sp_types: tuple[type, ...] = ( - nt, - DataArray, - Sequence, - Iterator, - np.ndarray, - ) - else: - sp_types = ( - nt, - Sequence, - Iterator, - np.ndarray, - ) - if not _is_nested_sequence_or_none(setpoints, sp_types, shapes): + if not _is_nested_sequence_or_none(setpoints, _SP_TYPES, shapes): raise ValueError("setpoints must be a tuple of tuples of arrays") if not _is_nested_sequence_or_none(setpoint_names, (nt, str), shapes): diff --git a/src/qcodes/sphinx_extensions/parse_parameter_attr.py b/src/qcodes/sphinx_extensions/parse_parameter_attr.py index 4ac6f61069a..4e118a5d680 100644 --- a/src/qcodes/sphinx_extensions/parse_parameter_attr.py +++ b/src/qcodes/sphinx_extensions/parse_parameter_attr.py @@ -63,7 +63,7 @@ def find_init_func( for child in node.children: if ( isinstance(child, parso.python.tree.Function) - and child.name.value # pyright: ignore[reportGeneralTypeIssues] + and child.name.value # pyright: ignore[reportAttributeAccessIssue] == "__init__" ): nodes.append(child) diff --git a/src/qcodes/utils/deprecate.py b/src/qcodes/utils/deprecate.py index 6c50ce262bc..3b8d23651e5 100644 --- a/src/qcodes/utils/deprecate.py +++ b/src/qcodes/utils/deprecate.py @@ -77,7 +77,7 @@ def actual_decorator(obj: Any) -> Any: if isinstance(obj, (types.FunctionType, types.MethodType)): func = cast(Callable[..., Any], obj) # pylint: disable=no-value-for-parameter - return decorate_callable(func) # pyright: ignore[reportGeneralTypeIssues] + return decorate_callable(func) # pyright: ignore[reportCallIssue] # pylint: enable=no-value-for-parameter else: # this would need to be recursive @@ -98,9 +98,7 @@ def actual_decorator(obj: Any) -> Any: setattr( obj, m_name, - decorate_callable( - m - ), # pyright: ignore[reportGeneralTypeIssues] + decorate_callable(m), # pyright: ignore[reportCallIssue] ) # pylint: enable=no-value-for-parameter return obj diff --git a/src/qcodes/utils/spyder_utils.py b/src/qcodes/utils/spyder_utils.py index c5744865d77..f7fa14361c3 100644 --- a/src/qcodes/utils/spyder_utils.py +++ b/src/qcodes/utils/spyder_utils.py @@ -44,7 +44,7 @@ def add_to_spyder_UMR_excludelist(modulename: str) -> None: if modulename not in excludednamelist: _LOG.info(f"adding {modulename} to excluded modules") excludednamelist.append(modulename) - sitecustomize.__umr__ = sitecustomize.UserModuleReloader( # pyright: ignore[reportUnboundVariable] + sitecustomize.__umr__ = sitecustomize.UserModuleReloader( # pyright: ignore[reportPossiblyUnboundVariable] namelist=excludednamelist ) os.environ["SPY_UMR_NAMELIST"] = ",".join(excludednamelist)