Skip to content

Commit

Permalink
Merge pull request #331 from jenshnielsen/mypy980
Browse files Browse the repository at this point in the history
Type check with mypy 0.981
  • Loading branch information
jenshnielsen committed Sep 27, 2022
2 parents a17b024 + 33b6499 commit 034dded
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 24 deletions.
4 changes: 2 additions & 2 deletions plottr/analyzer/fitters/experiment_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class T1_Decay(Fit):
@staticmethod
def model(coordinates: np.ndarray, amp: float, tau: float) -> np.ndarray: # type: ignore[override]
def model(coordinates: np.ndarray, amp: float, tau: float) -> np.ndarray:
""" amp * exp(-1.0 * x / tau)"""
return amp * np.exp(-1.0 * coordinates / tau)
@staticmethod
Expand All @@ -18,7 +18,7 @@ def guess(coordinates: Union[Tuple[np.ndarray, ...], np.ndarray],

class T2_Ramsey(Fit):
@staticmethod
def model(coordinates: np.ndarray, amp: float, tau: float, freq: float, phase: float) -> np.ndarray: # type: ignore[override]
def model(coordinates: np.ndarray, amp: float, tau: float, freq: float, phase: float) -> np.ndarray:
""" amp * exp(-1.0 * x / tau) * sin(2 * PI * freq * x + phase) """
return amp * np.exp(-1.0 * coordinates / tau) * \
np.sin(2 * np.pi * freq * coordinates + phase)
Expand Down
4 changes: 2 additions & 2 deletions plottr/analyzer/fitters/generic_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Cosine(Fit):
@staticmethod
def model(coordinates: np.ndarray, # type: ignore[override]
def model(coordinates: np.ndarray,
A: float, f: float, phi: float, of: float) -> np.ndarray:
"""$A \cos(2 \pi f x + \phi) + of$"""
return A * np.cos(2 * np.pi * coordinates * f + phi) + of
Expand All @@ -34,7 +34,7 @@ def guess(coordinates: Union[Tuple[np.ndarray, ...], np.ndarray],

class Exponential(Fit):
@staticmethod
def model(coordinates: np.ndarray, a: float, b: float) -> np.ndarray: # type: ignore[override]
def model(coordinates: np.ndarray, a: float, b: float) -> np.ndarray:
""" a * b ** x"""
return a * b ** coordinates

Expand Down
4 changes: 2 additions & 2 deletions plottr/data/datadict_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def __init__(self, name: str):
def filepath(self) -> Optional[str]:
return self._filepath

@filepath.setter # type: ignore[misc]
@filepath.setter
@updateOption('filepath')
def filepath(self, val: str) -> None:
self._filepath = val
Expand All @@ -443,7 +443,7 @@ def filepath(self, val: str) -> None:
def groupname(self) -> str:
return self._groupname

@groupname.setter # type: ignore[misc]
@groupname.setter
@updateOption('groupname')
def groupname(self, val: str) -> None:
self._groupname = val
Expand Down
3 changes: 1 addition & 2 deletions plottr/data/qcodes_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ def __init__(self, *arg: Any, **kw: Any):
def pathAndId(self) -> Tuple[Optional[str], Optional[int]]:
return self._pathAndId

# see https://github.com/python/mypy/issues/1362
@pathAndId.setter # type: ignore[misc]
@pathAndId.setter
@updateOption('pathAndId')
def pathAndId(self, val: Tuple[Optional[str], Optional[int]]) -> None:
if val != self.pathAndId:
Expand Down
4 changes: 2 additions & 2 deletions plottr/node/data_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ def __init__(self, name: str):
super().__init__(name)

self._dataStructure = None
self.selectedData = [] # type: ignore[misc]
self.selectedData = []

# Properties

@property
def selectedData(self) -> List[str]:
return self._selectedData

@selectedData.setter # type: ignore[misc]
@selectedData.setter
@updateOption('selectedData')
def selectedData(self, val: List[str]) -> None:
if isinstance(val, str):
Expand Down
13 changes: 6 additions & 7 deletions plottr/node/dim_reducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def __init__(self, name: str):
def reductions(self) -> Dict[str, Optional[ReductionType]]:
return self._reductions

@reductions.setter # type: ignore[misc]
@reductions.setter
@updateOption('reductions')
def reductions(self, val: Dict[str, Optional[ReductionType]]) -> None:
self._reductions = val
Expand All @@ -507,7 +507,7 @@ def reductions(self, val: Dict[str, Optional[ReductionType]]) -> None:
def targetNames(self) -> Optional[List[str]]:
return self._targetNames

@targetNames.setter # type: ignore[misc]
@targetNames.setter
@updateOption()
def targetNames(self, val: Optional[List[str]]) -> None:
self._targetNames = val
Expand All @@ -516,7 +516,7 @@ def targetNames(self, val: Optional[List[str]]) -> None:
def reductionValues(self) -> Dict[str, float]:
return self._reductionValues

@reductionValues.setter # type: ignore[misc]
@reductionValues.setter
@updateOption('reductionValues')
def reductionValues(self, val: Dict[str, float]) -> None:
self._reductionValues = val
Expand Down Expand Up @@ -595,8 +595,7 @@ def _applyDimReductions(self, data: DataDictBase) -> Optional[DataDictBase]:
data = data.sanitize()
data.validate()
if self.reductionValues != reductionValues:
self.reductionValues = reductionValues # type: ignore[misc]
# Open bug: https://github.com/python/mypy/issues/1465
self.reductionValues = reductionValues
return data

def validateOptions(self, data: DataDictBase) -> bool:
Expand Down Expand Up @@ -779,7 +778,7 @@ def __init__(self, name: str):
def xyAxes(self) -> Tuple[Optional[str], Optional[str]]:
return self._xyAxes

@xyAxes.setter # type: ignore[misc]
@xyAxes.setter
@updateOption('xyAxes')
def xyAxes(self, val: Tuple[Optional[str], Optional[str]]) -> None:
self._xyAxes = val
Expand All @@ -795,7 +794,7 @@ def dimensionRoles(self) -> Dict[str, Union[str, ReductionType, None]]:
dr[dim] = red
return dr

@dimensionRoles.setter # type: ignore[misc]
@dimensionRoles.setter
@updateOption('dimensionRoles')
def dimensionRoles(self, val: Dict[str, str]) -> None:
x = None
Expand Down
2 changes: 1 addition & 1 deletion plottr/node/filter/correct_offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, name: str):
def averagingAxis(self) -> Optional[str]:
return self._averagingAxis

@averagingAxis.setter # type: ignore[misc]
@averagingAxis.setter
@updateOption('averagingAxis')
def averagingAxis(self, value: str) -> None:
self._averagingAxis = value
Expand Down
2 changes: 1 addition & 1 deletion plottr/node/fitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def process(self, dataIn: Optional[DataDictBase] = None) -> Optional[Dict[str, O
def fitting_options(self) -> Optional[FittingOptions]:
return self._fitting_options

@fitting_options.setter # type: ignore[misc] # https://github.com/python/mypy/issues/1362
@fitting_options.setter
@updateOption('fitting_options')
def fitting_options(self, opt: Optional[FittingOptions]) -> None:
if isinstance(opt, FittingOptions) or opt is None:
Expand Down
2 changes: 1 addition & 1 deletion plottr/node/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def grid(self) -> Tuple[GridOption, Dict[str, Any]]:
"""
return self._grid

@grid.setter # type: ignore[misc]
@grid.setter
@updateOption('grid')
def grid(self, val: Tuple[GridOption, Dict[str, Any]]) -> None:
"""set the grid option. does some elementary type checking, but should
Expand Down
4 changes: 2 additions & 2 deletions plottr/node/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __init__(self, name: str) -> None:
def nbins(self) -> int:
return self._nbins

@nbins.setter # type: ignore[misc]
@nbins.setter
@updateOption('nbins')
def nbins(self, value: int) -> None:
self._nbins = value
Expand All @@ -114,7 +114,7 @@ def nbins(self, value: int) -> None:
def histogramAxis(self) -> Optional[str]:
return self._histogramAxis

@histogramAxis.setter # type: ignore[misc]
@histogramAxis.setter
@updateOption('histogramAxis')
def histogramAxis(self, value: Optional[str]) -> None:
self._histogramAxis = value
Expand Down
2 changes: 1 addition & 1 deletion plottr/node/scaleunits.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __init__(self, name: str):
def scale_unit_option(self) -> ScaleUnitsOption:
return self._scale_unit_option

@scale_unit_option.setter # type: ignore[misc]
@scale_unit_option.setter
@updateOption('scale_unit_option')
def scale_unit_option(self, value: ScaleUnitsOption) -> None:
self._scale_unit_option = value
Expand Down
2 changes: 1 addition & 1 deletion test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
qcodes
pytest
pytest-qt
mypy==0.971
mypy==0.981
PyQt5-stubs==5.15.6.0
pandas-stubs

0 comments on commit 034dded

Please sign in to comment.