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

Drop isort and pydocstyle in favor of ruff and pin to 0.6.0 and above #321

Merged
merged 12 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
16 changes: 1 addition & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
files: mne_lsl

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
rev: v0.6.0
hooks:
- id: ruff
name: ruff linter
args: [--fix, --show-fixes]
files: mne_lsl
- id: ruff-format
name: ruff formatter
files: mne_lsl

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
Expand All @@ -23,13 +16,6 @@ repos:
args: [--write-changes]
additional_dependencies: [tomli]

- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
files: mne_lsl
additional_dependencies: [tomli]

- repo: https://github.com/mscheltienne/bibclean
rev: 0.8.0
hooks:
Expand Down
1 change: 0 additions & 1 deletion examples/00_player_separate_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from mne_lsl.datasets import sample
from mne_lsl.player import PlayerLSL as Player


raw = read_raw_fif(sample.data_path() / "sample-ecg-raw.fif", preload=False)
raw.crop(0, 3).load_data()
player = Player(raw, chunk_size=200, n_repeat=1, name="example-process")
Expand Down
4 changes: 2 additions & 2 deletions examples/10_peak_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@
from time import sleep

import numpy as np
from mne_lsl.stream import StreamLSL
from numpy.typing import NDArray
from scipy.signal import find_peaks

from mne_lsl.stream import StreamLSL

ECG_HEIGHT: float = 98.0 # percentile height constraint, in %
ECG_DISTANCE: float = 0.5 # distance constraint, in seconds
Expand Down Expand Up @@ -253,10 +253,10 @@ def detect_peaks(self) -> NDArray[np.float64]:
from time import sleep

import numpy as np
from mne_lsl.stream import StreamLSL
from numpy.typing import NDArray
from scipy.signal import find_peaks

from mne_lsl.stream import StreamLSL

ECG_HEIGHT: float = 98.0 # percentile height constraint, in %
ECG_DISTANCE: float = 0.5 # distance constraint, in seconds
Expand Down
2 changes: 1 addition & 1 deletion examples/40_decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from mne.decoding import Vectorizer
from mne.io import read_raw_fif
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import Pipeline
from sklearn.model_selection import ShuffleSplit, cross_val_score
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler

from mne_lsl.datasets import sample
Expand Down
4 changes: 2 additions & 2 deletions mne_lsl/commands/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


@click.group()
def run() -> None: # noqa: D401
"""Main package entry-point."""
def run() -> None:
"""Main package entry-point.""" # noqa: D401


run.add_command(player)
Expand Down
6 changes: 3 additions & 3 deletions mne_lsl/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _closer():
outlets.clear()


@pytest.fixture()
@pytest.fixture
def close_io():
"""Return function that will close inlets and outlets if present."""
return _closer
Expand All @@ -127,13 +127,13 @@ def fname(tmp_path_factory) -> Path:
return fname_mod


@pytest.fixture()
@pytest.fixture
def raw(fname: Path) -> BaseRaw:
"""Return the raw file corresponding to fname."""
return read_raw_fif(fname, preload=True)


@pytest.fixture()
@pytest.fixture
def raw_annotations(raw: BaseRaw) -> BaseRaw:
"""Return a raw file with annotations."""
annotations = Annotations(
Expand Down
4 changes: 2 additions & 2 deletions mne_lsl/datasets/tests/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from typing import Optional


@pytest.fixture()
@pytest.fixture
def license_file() -> Optional[Path]:
"""Find the license file if present."""
fname = Path(__file__).parent.parent.parent.parent / "LICENSE"
Expand All @@ -22,7 +22,7 @@ def license_file() -> Optional[Path]:
pytest.skip("License file not found.")


@pytest.fixture()
@pytest.fixture
def license_url() -> str:
"""Return the URL for the license file."""
return "https://raw.githubusercontent.com/mne-tools/mne-lsl/main/"
Expand Down
24 changes: 12 additions & 12 deletions mne_lsl/lsl/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ def parent(self):
return XMLElement(lib.lsl_parent(self.e))

# -- Content Queries ------------------------------------------------------
def empty(self): # noqa: D401
"""True if this node is empty."""
def empty(self):
"""True if this node is empty.""" # noqa: D401
return bool(lib.lsl_empty(self.e))

def is_text(self): # noqa: D401
def is_text(self):
"""True if this node is a text body (instead of an XML element).

True both for plain char data and CData.
"""
""" # noqa: D401
return bool(lib.lsl_is_text(self.e))

def name(self):
Expand All @@ -87,26 +87,26 @@ def child_value(self, name=None):
return res.decode("utf-8")

# -- Modification ---------------------------------------------------------
def append_child_value(self, name, value): # noqa: D205, D400
def append_child_value(self, name, value):
"""Append a child node with a given name, which has a (nameless) plain-text
child with the given text value.
"""
""" # noqa: D205, D400
return XMLElement(
lib.lsl_append_child_value(self.e, str.encode(name), str.encode(value))
)

def prepend_child_value(self, name, value): # noqa: D205, D400
def prepend_child_value(self, name, value):
"""Prepend a child node with a given name, which has a (nameless) plain-text
child with the given text value.
"""
""" # noqa: D205, D400
return XMLElement(
lib.lsl_prepend_child_value(self.e, str.encode(name), str.encode(value))
)

def set_child_value(self, name, value): # noqa: D205, D400
"""Set the text value of the (nameless) plain-text child of a named
child node.
"""
def set_child_value(self, name, value):
"""Set the text value of the (nameless) plain-text child of a named child
node.
""" # noqa: D205, D400
return XMLElement(
lib.lsl_set_child_value(self.e, str.encode(name), str.encode(value))
)
Expand Down
4 changes: 2 additions & 2 deletions mne_lsl/lsl/_utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class XMLElement:
"""

def set_child_value(self, name, value):
"""Set the text value of the (nameless) plain-text child of a named
child node.
"""Set the text value of the (nameless) plain-text child of a named child
node.
"""

def set_name(self, name):
Expand Down
2 changes: 1 addition & 1 deletion mne_lsl/lsl/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_local_clock():


@pytest.mark.xfail(reason="Fails if streams are present in the background.")
@pytest.mark.slow()
@pytest.mark.slow
def test_resolve_streams():
"""Test detection of streams on the network."""
streams = resolve_streams(timeout=0.1)
Expand Down
2 changes: 1 addition & 1 deletion mne_lsl/lsl/tests/test_load_liblsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def download_liblsl_outdated(tmp_path_factory) -> Path:
return Path(libpath)


@pytest.fixture()
@pytest.fixture
def liblsl_outdated(tmp_path, download_liblsl_outdated) -> Path:
"""Fixture to provide an outdated liblsl version."""
copy(download_liblsl_outdated, tmp_path / download_liblsl_outdated.name)
Expand Down
4 changes: 2 additions & 2 deletions mne_lsl/lsl/tests/test_stream_outlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def test_invalid_outlet():
StreamOutlet(sinfo, max_buffered=-101)


@pytest.mark.slow()
@pytest.mark.slow
@pytest.mark.parametrize(
("dtype_str", "dtype"),
[
Expand Down Expand Up @@ -221,7 +221,7 @@ def test_push_chunk_timestamps(dtype_str, dtype, close_io):
close_io()


@pytest.mark.slow()
@pytest.mark.slow
def test_push_chunk_irregularly_sampled_stream(close_io):
"""Test pushing a chunk on an irregularly sampled stream."""
x = np.array([[1, 4], [2, 5], [3, 6]], dtype=np.float32)
Expand Down
2 changes: 1 addition & 1 deletion mne_lsl/player/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
from mne.io.meas_info import ContainsMixin, SetChannelsMixin
from mne.io.pick import _picks_to_idx
else:
from mne.channels.channels import SetChannelsMixin
from mne.io.meas_info import ContainsMixin
from mne.io.pick import _picks_to_idx
from mne.channels.channels import SetChannelsMixin

from ..utils._checks import check_type, ensure_int, ensure_path
from ..utils._docs import fill_doc
Expand Down
16 changes: 8 additions & 8 deletions mne_lsl/player/tests/test_player_lsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def _create_inlet(name: str, source_id: str) -> StreamInlet:
return inlet


@pytest.fixture()
@pytest.fixture
def mock_lsl_stream(fname: Path, chunk_size, request):
"""Create a mock LSL stream for testing."""
# nest the PlayerLSL import to first write the temporary LSL configuration file
Expand All @@ -227,7 +227,7 @@ def mock_lsl_stream(fname: Path, chunk_size, request):
yield player


@pytest.mark.slow()
@pytest.mark.slow
def test_player_unit(mock_lsl_stream, raw, close_io):
"""Test getting and setting the player channel units."""
player = mock_lsl_stream
Expand Down Expand Up @@ -270,7 +270,7 @@ def test_player_unit(mock_lsl_stream, raw, close_io):
player.stop()


@pytest.mark.slow()
@pytest.mark.slow
def test_player_rename_channels(mock_lsl_stream, raw, close_io):
"""Test channel renaming."""
player = mock_lsl_stream
Expand Down Expand Up @@ -306,7 +306,7 @@ def test_player_rename_channels(mock_lsl_stream, raw, close_io):
player.stop()


@pytest.mark.slow()
@pytest.mark.slow
def test_player_set_channel_types(mock_lsl_stream, raw, close_io):
"""Test channel type setting."""
player = mock_lsl_stream
Expand Down Expand Up @@ -388,7 +388,7 @@ def test_player_set_meas_date(fname, chunk_size, request):
player.stop()


@pytest.mark.slow()
@pytest.mark.slow
def test_player_annotations(raw_annotations, close_io, chunk_size, request):
"""Test player with annotations."""
name = f"P_{request.node.name}"
Expand Down Expand Up @@ -457,7 +457,7 @@ def test_player_annotations(raw_annotations, close_io, chunk_size, request):
player.stop()


@pytest.fixture()
@pytest.fixture
def raw_annotations_1000_samples() -> BaseRaw:
"""Return a 1000 sample raw object with annotations."""
n_samples = 1000
Expand All @@ -475,7 +475,7 @@ def raw_annotations_1000_samples() -> BaseRaw:
return raw.drop_channels("trg").set_annotations(annotations)


@pytest.mark.slow()
@pytest.mark.slow
def test_player_annotations_multiple_of_chunk_size(
raw_annotations_1000_samples, chunk_size, request
):
Expand All @@ -501,7 +501,7 @@ def test_player_annotations_multiple_of_chunk_size(
player.stop()


@pytest.mark.slow()
@pytest.mark.slow
def test_player_n_repeat(raw, chunk_size, request):
"""Test argument 'n_repeat'."""
name = f"P_{request.node.name}"
Expand Down
Loading
Loading