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

Add config and an optional dependency for type checking with mypy #275

Merged
merged 1 commit into from
May 8, 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
4 changes: 2 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ source ./buildenv/bin/activate

8. Install Friture dependencies (PyQt5, etc.)
```
pip3.11 install .
pip3.11 install .[dev]
```

9. Build Cython extensions
Expand Down Expand Up @@ -114,7 +114,7 @@ virtualenv buildenv
8. Install dependencies

```
pip install .
pip install .[dev]
```

9. Build Cython extensions
Expand Down
12 changes: 6 additions & 6 deletions friture/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def __init__(self, parent=None):
self._coordinate_transform = CoordinateTransform(-1, 1, 1., 0, 0, self)
self._show_minor_grid_lines = False

@pyqtProperty(str, notify=name_changed)
@pyqtProperty(str, notify=name_changed) # type: ignore
def name(self):
return self._name

@name.setter
@name.setter # type: ignore
def name(self, name):
if self._name != name:
self._name = name
Expand All @@ -30,7 +30,7 @@ def setTrackerFormatter(self, formatter):
if self._formatter != formatter:
self._formatter = formatter

@pyqtSlot(float, result=str)
@pyqtSlot(float, result=str) # type: ignore
def formatTracker(self, value):
return self._formatter(value)

Expand All @@ -42,18 +42,18 @@ def setScale(self, scale):
self._scale_division.setScale(scale)
self._coordinate_transform.setScale(scale)

@pyqtProperty(ScaleDivision, constant=True)
@pyqtProperty(ScaleDivision, constant=True) # type: ignore
def scale_division(self):
return self._scale_division

@pyqtProperty(bool, constant=True)
@pyqtProperty(bool, constant=True) # type: ignore
def show_minor_grid_lines(self) -> bool:
return self._show_minor_grid_lines

@show_minor_grid_lines.setter # type: ignore
def show_minor_grid_lines(self, show: bool):
self._show_minor_grid_lines = show

@pyqtProperty(CoordinateTransform, constant=True)
@pyqtProperty(CoordinateTransform, constant=True) # type: ignore
def coordinate_transform(self):
return self._coordinate_transform
6 changes: 3 additions & 3 deletions friture/ballistic_peak.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# along with Friture. If not, see <http://www.gnu.org/licenses/>.

from PyQt5 import QtCore
from PyQt5.QtCore import pyqtProperty
from PyQt5.QtCore import pyqtProperty # type: ignore

PEAK_DECAY_RATE = (1.0 - 3E-6/500.)
# Number of cycles the peak stays on hold before fall-off.
Expand All @@ -37,8 +37,8 @@ def __init__(self, parent=None):
@pyqtProperty(float, notify=peak_changed)
def peak_iec(self):
return self._peak_iec
@peak_iec.setter

@peak_iec.setter # type: ignore
def peak_iec(self, peak_iec):

# peak-hold-then-decay mechanism
Expand Down
6 changes: 3 additions & 3 deletions friture/bar_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ def setData(self, x, unscaled_x, y):
self._y = y
self.y_changed.emit()

@pyqtProperty(float, notify=x_changed)
@pyqtProperty(float, notify=x_changed) # type: ignore
def x(self):
return self._x

@pyqtProperty(float, notify=y_changed)
@pyqtProperty(float, notify=y_changed) # type: ignore
def y(self):
return self._y

@pyqtProperty(str, notify=unscaled_x_changed)
@pyqtProperty(str, notify=unscaled_x_changed) # type: ignore
def unscaled_x(self):
return self._unscaled_x
10 changes: 5 additions & 5 deletions friture/curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# along with Friture. If not, see <http://www.gnu.org/licenses/>.

from PyQt5 import QtCore
from PyQt5.QtCore import pyqtProperty
from PyQt5.QtCore import pyqtProperty # type: ignore
import numpy

class Curve(QtCore.QObject):
Expand All @@ -36,18 +36,18 @@ def setData(self, x_array, y_array):
self._x_array = x_array
self._y_array = y_array
self.data_changed.emit()

def x_array(self):
return self._x_array

def y_array(self):
return self._y_array

@pyqtProperty(str, notify=name_changed)
def name(self):
return self._name
@name.setter

@name.setter # type: ignore
def name(self, name):
if self._name != name:
self._name = name
Expand Down
12 changes: 6 additions & 6 deletions friture/filled_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def setData(self, x_left_array, x_right_array, y_array, z_array, baseline):
self._z_array = z_array
self._baseline = baseline
self.data_changed.emit()

def x_left_array(self):
return self._x_left_array

Expand All @@ -64,17 +64,17 @@ def z_array(self):

def baseline(self):
return self._baseline

@pyqtProperty(str, notify=name_changed)
def name(self):
return self._name
@name.setter

@name.setter # type: ignore
def name(self, name):
if self._name != name:
self._name = name
self.name_changed.emit(name)
@pyqtProperty(CurveType, constant = True)

@pyqtProperty(int, constant = True) # type: ignore
def curve_type(self):
return self._curve_type
10 changes: 5 additions & 5 deletions friture/histplot_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from PyQt5 import QtCore
from PyQt5.QtCore import pyqtProperty
from PyQt5.QtQml import QQmlListProperty
from PyQt5.QtQml import QQmlListProperty # type: ignore

from friture.bar_label import BarLabel
from friture.scope_data import Scope_Data
Expand All @@ -33,15 +33,15 @@ def __init__(self, parent=None):

self._bar_labels = []
self._bar_labels_x_distance = 0.

def setBarLabels(self, x, unscaled_x, y):
x_distance = x[1] - x[0]
if self._bar_labels_x_distance != x_distance:
self._bar_labels_x_distance = x_distance
self.bar_labels_x_distance_changed.emit()

label_count = x.shape[0]

# never display more than 60 labels
# it is not useful visually
# and the loop to build them would be too slow
Expand All @@ -55,10 +55,10 @@ def setBarLabels(self, x, unscaled_x, y):
for i in range(label_count):
self._bar_labels[i].setData(x[i], unscaled_x[i], y[i])

@pyqtProperty(QQmlListProperty, notify=bar_labels_changed)
@pyqtProperty(QQmlListProperty, notify=bar_labels_changed) # type: ignore
def barLabels(self):
return QQmlListProperty(BarLabel, self, self._bar_labels)

@pyqtProperty(float, notify=bar_labels_x_distance_changed)
@pyqtProperty(float, notify=bar_labels_x_distance_changed) # type: ignore
def bar_labels_x_distance(self):
return self._bar_labels_x_distance
18 changes: 9 additions & 9 deletions friture/level_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,29 @@ def __init__(self, parent=None):
self._level_rms = -30.
self._level_max = -30.

@pyqtProperty(float, notify=level_rms_changed)
@pyqtProperty(float, notify=level_rms_changed) # type: ignore
def level_rms(self):
return self._level_rms
@pyqtProperty(float, notify=level_rms_changed)

@pyqtProperty(float, notify=level_rms_changed) # type: ignore
def level_rms_iec(self):
return dB_to_IEC(self._level_rms)
@level_rms.setter

@level_rms.setter # type: ignore
def level_rms(self, level_rms):
if self._level_rms != level_rms:
self._level_rms = level_rms
self.level_rms_changed.emit(level_rms)

@pyqtProperty(float, notify=level_max_changed)
@pyqtProperty(float, notify=level_max_changed) # type: ignore
def level_max(self):
return self._level_max

@pyqtProperty(float, notify=level_max_changed)
@pyqtProperty(float, notify=level_max_changed) # type: ignore
def level_max_iec(self):
return dB_to_IEC(self._level_max)
@level_max.setter

@level_max.setter # type: ignore
def level_max(self, level_max):
if self._level_max != level_max:
self._level_max = level_max
Expand Down
28 changes: 14 additions & 14 deletions friture/level_view_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,36 +38,36 @@ def __init__(self, parent=None):
self._level_data_ballistic = BallisticPeak(self)
self._level_data_ballistic_2 = BallisticPeak(self)

@pyqtProperty(bool, notify=two_channels_changed)
@pyqtProperty(bool, notify=two_channels_changed) # type: ignore
def two_channels(self):
return self._two_channels
@two_channels.setter

@two_channels.setter # type: ignore
def two_channels(self, two_channels):
if self._two_channels != two_channels:
self._two_channels = two_channels
self.two_channels_changed.emit(two_channels)

@pyqtProperty(LevelData, constant = True)
@pyqtProperty(LevelData, constant = True) # type: ignore
def level_data(self):
return self._level_data
@pyqtProperty(LevelData, constant = True)

@pyqtProperty(LevelData, constant = True) # type: ignore
def level_data_2(self):
return self._level_data_2
@pyqtProperty(LevelData, constant = True)

@pyqtProperty(LevelData, constant = True) # type: ignore
def level_data_slow(self):
return self._level_data_slow
@pyqtProperty(LevelData, constant = True)

@pyqtProperty(LevelData, constant = True) # type: ignore
def level_data_slow_2(self):
return self._level_data_slow_2
@pyqtProperty(LevelData, constant = True)

@pyqtProperty(LevelData, constant = True) # type: ignore
def level_data_ballistic(self):
return self._level_data_ballistic
@pyqtProperty(LevelData, constant = True)

@pyqtProperty(LevelData, constant = True) # type: ignore
def level_data_ballistic_2(self):
return self._level_data_ballistic_2
6 changes: 3 additions & 3 deletions friture/levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from PyQt5 import QtWidgets
from PyQt5.QtQml import QQmlComponent
from PyQt5.QtQuick import QQuickWindow
from PyQt5.QtQuick import QQuickWindow # type: ignore
import numpy as np

from friture.store import GetStore
Expand Down Expand Up @@ -62,7 +62,7 @@ def __init__(self, parent, engine):
self.qmlObject.setParent(self.quickWindow)

self.quickWidget = QtWidgets.QWidget.createWindowContainer(self.quickWindow, self)
self.quickWidget.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
self.quickWidget.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addWidget(self.quickWidget)

self.qmlObject.widthChanged.connect(self.onWidthChanged)
Expand Down Expand Up @@ -174,7 +174,7 @@ def canvasUpdate(self):
if self.two_channels:
self.level_view_model.level_data_slow_2.level_rms = self.level_view_model.level_data_2.level_rms
self.level_view_model.level_data_slow_2.level_max = self.level_view_model.level_data_2.level_max

self.i = self.i % LEVEL_TEXT_LABEL_STEPS

# slot
Expand Down
Loading
Loading