Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
4938: Check pyright in CI r=jenshnielsen a=jenshnielsen

Fix one last remaining type checking issue too

* Also fix a use of deprecated MeasurementStatus 
* Remove deleted modules from type exclusions

Co-authored-by: Jens H. Nielsen <[email protected]>
Co-authored-by: Jens H. Nielsen <[email protected]>
  • Loading branch information
3 people authored Jan 23, 2023
2 parents 69d35e0 + 651d658 commit bd97e3a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ jobs:
- name: install qcodes
run: |
pip install .[test] -c requirements.txt
- uses: jakebailey/[email protected]
with:
version: 1.1.289
- name: Run Mypy
run: mypy -p qcodes
- name: Run parallel tests
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ Our required checks consists of a number of jobs that performs the following act
on Linux and on Windows.

- Run our test suite using pytest as described above.
- Perform type checking of the code in QCoDeS using MyPy. For many of the modules we enforce that the code must be
- Perform type checking of the code in QCoDeS using MyPy and Pyright. For many of the modules we enforce that the code must be
type annotated. We encourage all contributors to type annotate any contribution to QCoDeS. If you need help with this
please feel free to reach out.
please feel free to reach out. Pyright typechecks can be performed inline within VC-code using the Pylance extension.
- Build the documentation using Sphinx with Sphinx warnings as errors. This includes execution of all example notebooks
that are not explicitly marked as not to be executed. Please see here_ for information on how to disable execution of a
notebook.
Expand Down
2 changes: 2 additions & 0 deletions docs/changes/newsfragments/4938.improved
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
QcoDeS is now typechecked with Pyright in addition to mypy. This should give a significantly
better user experience when working in VS Code.
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ module = [
"qcodes.instrument.mockers.ami430",
"qcodes.instrument_drivers.Harvard.*",
"qcodes.instrument_drivers.Keysight.keysightb1500.message_builder.*",
"qcodes.instrument_drivers.oxford.mercuryiPS",
"qcodes.instrument_drivers.test",
"qcodes.loops",
"qcodes.math_utils.*",
"qcodes.measure",
Expand Down Expand Up @@ -233,10 +231,8 @@ ignore_missing_imports = true
include = ["qcodes"]
ignore = [
"qcodes/tests",
"qcodes/instrument_drivers/test.py",
"qcodes/instrument_drivers/zurich_instruments",
"qcodes/instrument_drivers/Harvard/Decadac.py",
"qcodes/instrument_drivers/oxford/mercuryiPS.py",
"qcodes/actions.py",
"qcodes/data",
"qcodes/loops.py",
Expand Down
12 changes: 11 additions & 1 deletion qcodes/instrument/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import time
import weakref
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, Protocol, TypeVar, cast
from typing import TYPE_CHECKING, Any, Protocol, TypeVar, cast, overload

from qcodes.utils import strip_attrs
from qcodes.validators import Anything
Expand Down Expand Up @@ -259,6 +259,16 @@ def remove_instance(cls, instance: Instrument) -> None:
if ref is instance:
del all_ins[name]

@overload
@classmethod
def find_instrument(cls, name: str, instrument_class: None = None) -> Instrument:
...

@overload
@classmethod
def find_instrument(cls, name: str, instrument_class: type[T]) -> T:
...

@classmethod
def find_instrument(cls, name: str, instrument_class: type[T] | None = None) -> T:
"""
Expand Down
6 changes: 3 additions & 3 deletions qcodes/instrument_drivers/Keithley/_Keithley_2600.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,14 @@ class _ParameterWithStatus(Parameter):
def __init__(self, *args: Any, **kwargs: Any):
super().__init__(*args, **kwargs)

self._measurement_status: Optional[MeasurementStatus] = None
self._measurement_status: Optional[Keithley2600MeasurementStatus] = None

@property
def measurement_status(self) -> Optional[MeasurementStatus]:
def measurement_status(self) -> Optional[Keithley2600MeasurementStatus]:
return self._measurement_status

@staticmethod
def _parse_response(data: str) -> Tuple[float, MeasurementStatus]:
def _parse_response(data: str) -> Tuple[float, Keithley2600MeasurementStatus]:
value, meas_status = data.split("\t")

status_bits = [
Expand Down

0 comments on commit bd97e3a

Please sign in to comment.