Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#283)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Aug 20, 2024
1 parent cfa0f60 commit 6bed7d3
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 40 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/qt_viz_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
1 change: 0 additions & 1 deletion mne_qt_browser/_fixes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Backports for older installations."""

# Author: Martin Schulz <[email protected]>
Expand Down
43 changes: 13 additions & 30 deletions mne_qt_browser/_pg_figure.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Base classes and functions for 2D browser backends."""

# Author: Martin Schulz <[email protected]>
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
1 change: 0 additions & 1 deletion mne_qt_browser/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Authors: Eric Larson <[email protected]>
# Martin Schulz <[email protected]>
#
Expand Down
1 change: 0 additions & 1 deletion mne_qt_browser/tests/test_pg_specific.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Author: Martin Schulz <[email protected]>
#
# License: BSD-3-Clause
Expand Down
1 change: 0 additions & 1 deletion mne_qt_browser/tests/test_speed.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Authors: Eric Larson <[email protected]>
# Martin Schulz <[email protected]>
#
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]" }]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6bed7d3

Please sign in to comment.