Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade pyright to 1.1.349 #5659

Merged
merged 6 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,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
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ reportMissingTypeStubs = 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"
Expand Down
4 changes: 1 addition & 3 deletions src/qcodes/dataset/sqlite/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/qcodes/instrument_drivers/Keithley/_Keithley_2600.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@
self.instrument.trigger.force()
data = self.instrument.fetch()

return data # pyright: ignore[reportUnboundVariable]
return data # pyright: ignore[reportPossiblyUnboundVariable]

Check warning on line 396 in src/qcodes/instrument_drivers/Keysight/private/Keysight_344xxA_submodules.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/instrument_drivers/Keysight/private/Keysight_344xxA_submodules.py#L396

Added line #L396 was not covered by tests

def get_raw(self) -> np.ndarray: # pylint: disable=method-hidden

Expand Down
4 changes: 2 additions & 2 deletions src/qcodes/instrument_drivers/Minicircuits/USBHIDMixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
**kwargs: Any):
self._check_hid_import()

devs = hid.HidDeviceFilter(
devs = hid.HidDeviceFilter( # pyright: ignore[reportPossiblyUnboundVariable]

Check warning on line 50 in src/qcodes/instrument_drivers/Minicircuits/USBHIDMixin.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/instrument_drivers/Minicircuits/USBHIDMixin.py#L50

Added line #L50 was not covered by tests
product_id=self.product_id,
vendor_id=self.vendor_id,
instance_id=instance_id
Expand Down Expand Up @@ -144,7 +144,7 @@
"""
cls._check_hid_import()

devs = hid.HidDeviceFilter(
devs = hid.HidDeviceFilter( # pyright: ignore[reportPossiblyUnboundVariable]

Check warning on line 147 in src/qcodes/instrument_drivers/Minicircuits/USBHIDMixin.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/instrument_drivers/Minicircuits/USBHIDMixin.py#L147

Added line #L147 was not covered by tests
porduct_id=cls.product_id,
vendor_id=cls.vendor_id
).get_devices()
Expand Down
8 changes: 5 additions & 3 deletions src/qcodes/instrument_drivers/tektronix/AWG70000A.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
36 changes: 20 additions & 16 deletions src/qcodes/parameters/array_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (

Check warning on line 35 in src/qcodes/parameters/array_parameter.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/parameters/array_parameter.py#L34-L35

Added lines #L34 - L35 were not covered by tests
type(None),
collections.abc.Sequence,
collections.abc.Iterator,
np.ndarray,
)


class ArrayParameter(ParameterBase):
"""
A gettable parameter that returns an array of values.
Expand Down Expand Up @@ -154,23 +173,8 @@
# 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(
Expand Down
43 changes: 19 additions & 24 deletions src/qcodes/parameters/multi_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (

Check warning on line 26 in src/qcodes/parameters/multi_parameter.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/parameters/multi_parameter.py#L25-L26

Added lines #L25 - L26 were not covered by tests
type(None),
Sequence,
Iterator,
np.ndarray,
)


def _is_nested_sequence_or_none(
obj: Any,
Expand Down Expand Up @@ -180,22 +190,7 @@
)
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):
Expand Down
2 changes: 1 addition & 1 deletion src/qcodes/sphinx_extensions/parse_parameter_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions src/qcodes/utils/deprecate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/qcodes/utils/spyder_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
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]

Check warning on line 47 in src/qcodes/utils/spyder_utils.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/utils/spyder_utils.py#L47

Added line #L47 was not covered by tests
namelist=excludednamelist
)
os.environ["SPY_UMR_NAMELIST"] = ",".join(excludednamelist)
Loading