diff --git a/.github/workflows/qt_viz_tests.yml b/.github/workflows/qt_viz_tests.yml index f4c0151..8d28ca2 100644 --- a/.github/workflows/qt_viz_tests.yml +++ b/.github/workflows/qt_viz_tests.yml @@ -34,7 +34,7 @@ jobs: - os: ubuntu mne: maint/1.5 opengl: 'opengl' - python: '3.9' + python: '3.10' name: old - os: ubuntu mne: main @@ -111,7 +111,7 @@ jobs: os: [ubuntu] mne: [main] opengl: [opengl] - qt: [PyQt5, PyQt6, PySide2, PySide6] + qt: [PyQt5, PyQt6, PySide6] python: ['3.10'] # When going to 3.11, PySide2 should be removed or special-cased name: [matrix] include: @@ -189,7 +189,7 @@ jobs: # case given our primary target moving forward is Qt6+ - run: pytest mne_qt_browser/tests/test_speed.py --cov-report=xml --cov-append name: Run benchmarks - if: runner.os != 'Linux' || (matrix.qt != 'PySide2' && matrix.qt != 'PyQt5') + if: runner.os != 'Linux' || matrix.qt != 'PyQt5' - uses: codecov/codecov-action@v4 if: always() with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e938ab5..2300d49 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.7 + rev: v0.6.1 hooks: - id: ruff args: ["--fix"] diff --git a/mne_qt_browser/_fixes.py b/mne_qt_browser/_fixes.py index 05d2518..fc09472 100644 --- a/mne_qt_browser/_fixes.py +++ b/mne_qt_browser/_fixes.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """Backports for older installations.""" # Author: Martin Schulz diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index cee1f82..bc9b77c 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """Base classes and functions for 2D browser backends.""" # Author: Martin Schulz @@ -1457,7 +1456,7 @@ def mouseDragEvent(self, event, axis=None): self.mne.overview_bar.update_annotations() else: x_to = self.mapSceneToView(event.scenePos()).x() - with SignalBlocker(self._drag_region): + with QSignalBlocker(self._drag_region): self._drag_region.setRegion((self._drag_start, x_to)) elif event.isFinish(): @@ -2481,7 +2480,7 @@ def _region_changed(self): for region in overlapping_regions: self.weakmain()._remove_region(region, from_annot=False) # re-set while blocking the signal to avoid re-running this function - with SignalBlocker(self): + with QSignalBlocker(self): self.setRegion((onset, offset)) self.update_label_pos() @@ -2654,7 +2653,7 @@ def mouseDragEvent(self, ev): for pos in new_pos: pos.setX(pos.x() - shift) - with SignalBlocker(self.lines[0]): + with QSignalBlocker(self.lines[0]): for pos, line in zip(new_pos, self.lines): line.setPos(pos) self.prepareGeometryChange() @@ -3066,9 +3065,9 @@ def update_values(self, region): rgn = region.getRegion() self.start_bx.setEnabled(True) self.stop_bx.setEnabled(True) - with SignalBlocker(self.start_bx): + with QSignalBlocker(self.start_bx): self.start_bx.setValue(rgn[0]) - with SignalBlocker(self.stop_bx): + with QSignalBlocker(self.stop_bx): self.stop_bx.setValue(rgn[1]) def _update_description_cmbx(self): @@ -3087,9 +3086,9 @@ def reset(self): if self.description_cmbx.count() > 0: self.description_cmbx.setCurrentIndex(0) self.mne.current_description = self.description_cmbx.currentText() - with SignalBlocker(self.start_bx): + with QSignalBlocker(self.start_bx): self.start_bx.setValue(0) - with SignalBlocker(self.stop_bx): + with QSignalBlocker(self.stop_bx): self.stop_bx.setValue(1 / self.mne.info["sfreq"]) def _show_help(self): @@ -4096,7 +4095,7 @@ def hscroll(self, step): del step # Get current range and add step to it - xmin, xmax = [i + rel_step for i in self.mne.viewbox.viewRange()[0]] + xmin, xmax = (i + rel_step for i in self.mne.viewbox.viewRange()[0]) if xmin < 0: xmin = 0 @@ -4125,7 +4124,7 @@ def vscroll(self, step): step = self.mne.n_channels elif step == "-full": step = -self.mne.n_channels - ymin, ymax = [i + step for i in self.mne.viewbox.viewRange()[1]] + ymin, ymax = (i + step for i in self.mne.viewbox.viewRange()[1]) if ymin < 0: ymin = 0 @@ -4696,9 +4695,9 @@ def _remove_region(self, region, from_annot=True): # disable, reset start/stop doubleSpinBox until another region is selected self.mne.fig_annotation.start_bx.setEnabled(False) self.mne.fig_annotation.stop_bx.setEnabled(False) - with SignalBlocker(self.mne.fig_annotation.start_bx): + with QSignalBlocker(self.mne.fig_annotation.start_bx): self.mne.fig_annotation.start_bx.setValue(0) - with SignalBlocker(self.mne.fig_annotation.stop_bx): + with QSignalBlocker(self.mne.fig_annotation.stop_bx): self.mne.fig_annotation.stop_bx.setValue(1 / self.mne.info["sfreq"]) # Remove from annotations @@ -5191,12 +5190,12 @@ def _fake_click( add_points[idx] = self.mne.viewbox.mapViewToScene(Point(*apoint)) elif xform == "none" or xform is None: - if isinstance(point, (tuple, list)): + if isinstance(point, tuple | list): point = Point(*point) else: point = Point(point) for idx, apoint in enumerate(add_points): - if isinstance(apoint, (tuple, list)): + if isinstance(apoint, tuple | list): add_points[idx] = Point(*apoint) else: add_points[idx] = Point(apoint) @@ -5452,22 +5451,6 @@ def _init_browser(**kwargs): return browser -class SignalBlocker(QSignalBlocker): - """Wrapper to use QSignalBlocker as a context manager in PySide2.""" - - def __enter__(self): - if hasattr(super(), "__enter__"): - super().__enter__() - else: - super().reblock() - - def __exit__(self, exc_type, exc_value, traceback): - if hasattr(super(), "__exit__"): - super().__exit__(exc_type, exc_value, traceback) - else: - super().unblock() - - def _set_window_flags(widget): if os.getenv("_MNE_BROWSER_BACK", "").lower() == "true": widget.setWindowFlags(widget.windowFlags() | Qt.WindowStaysOnBottomHint) diff --git a/mne_qt_browser/conftest.py b/mne_qt_browser/conftest.py index 3132faa..1fbac71 100644 --- a/mne_qt_browser/conftest.py +++ b/mne_qt_browser/conftest.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Authors: Eric Larson # Martin Schulz # diff --git a/mne_qt_browser/tests/test_pg_specific.py b/mne_qt_browser/tests/test_pg_specific.py index f0a4767..25e3819 100644 --- a/mne_qt_browser/tests/test_pg_specific.py +++ b/mne_qt_browser/tests/test_pg_specific.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Author: Martin Schulz # # License: BSD-3-Clause diff --git a/mne_qt_browser/tests/test_speed.py b/mne_qt_browser/tests/test_speed.py index 72eedce..213b4e3 100644 --- a/mne_qt_browser/tests/test_speed.py +++ b/mne_qt_browser/tests/test_speed.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Authors: Eric Larson # Martin Schulz # diff --git a/pyproject.toml b/pyproject.toml index 45ea323..2007167 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" name = "mne-qt-browser" description = "A new backend based on pyqtgraph for the 2D-Data-Browser in MNE-Python" readme = "README.md" -requires-python = ">=3.9" +requires-python = ">=3.10" license = { file = "LICENSE" } keywords = ["science", "neuroscience", "psychology"] authors = [{ name = "Martin Schulz", email = "dev@mgschulz.de" }] @@ -68,7 +68,7 @@ filterwarnings = [ ] [tool.ruff.lint] -select = ["E", "F", "W", "D", "I"] +select = ["E", "F", "W", "D", "I", "UP"] exclude = ["__init__.py"] ignore = [ "D100", # Missing docstring in public module