Skip to content

Commit f974cbf

Browse files
Merge branch 'main' into fix/channel-mismatch
2 parents 5bbc24d + 5102e11 commit f974cbf

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.14.2
3+
rev: v0.14.3
44
hooks:
55
- id: ruff
66
name: ruff mne_bids/

doc/whats_new.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Detailed list of changes
5858

5959
- Fixed a bug that modified the name and help message of some of the available commands, by `Alex Lopez Marquez`_ (:gh:`1441`)
6060
- Updated MEG/iEEG writers to satisfy the stricter checks in the latest BIDS validator releases: BTi/4D run folders now retain their ``.pdf`` suffix (falling back to the legacy naming when an older validator is detected), KIT marker files encode the run via the ``acq`` entity instead of ``run``, datasets lacking iEEG montages receive placeholder ``electrodes.tsv``/``coordsystem.json`` files, and the ``AssociatedEmptyRoom`` entry stores dataset-relative paths by `Bruno Aristimunha`_ (:gh:`1449`)
61+
- Made the lock helpers skip reference counting when the optional ``filelock`` dependency is missing, preventing spurious ``AttributeError`` crashes during reads, by `Bruno Aristimunha`_ (:gh:`1469`)
6162
- Fixed a bug in :func:`mne_bids.read_raw_bids` that caused it to fail when reading BIDS datasets where the acquisition time was specified in local time rather than UTC only in Windows, by `Bruno Aristimunha`_ (:gh:`1452`)
6263

6364
⚕️ Code health

mne_bids/_fileio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def _increment_lock_refcount(file_path):
190190
refcount_lock_path = Path(f"{refcount_path}.lock")
191191

192192
filelock = _soft_import("filelock", purpose="lock refcounting", strict=False)
193-
if filelock is None:
193+
if not filelock:
194194
return
195195

196196
refcount_lock = filelock.FileLock(str(refcount_lock_path), timeout=5.0)
@@ -254,7 +254,7 @@ def _decrement_and_cleanup_lock_file(file_path):
254254
return
255255

256256
filelock = _soft_import("filelock", purpose="lock refcounting", strict=False)
257-
if filelock is None:
257+
if not filelock:
258258
return
259259

260260
refcount_lock = filelock.FileLock(str(refcount_lock_path), timeout=5.0)

mne_bids/tests/test_tsv_handler.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import pytest
99

10+
import mne_bids._fileio as _fileio
1011
from mne_bids.tsv_handler import (
1112
_combine_rows,
1213
_contains_row,
@@ -75,6 +76,23 @@ def test_tsv_handler(tmp_path):
7576
d = _drop(d, "n/a", "trial_type")
7677

7778

79+
def test_to_tsv_without_filelock(monkeypatch, tmp_path):
80+
"""Ensure TSV writes succeed when filelock is unavailable."""
81+
data = odict(a=[1, 2], b=["five", "six"])
82+
tsv_path = tmp_path / "file.tsv"
83+
lock_path = tsv_path.parent / f"{tsv_path.name}.lock"
84+
refcount_path = tsv_path.parent / f"{tsv_path.name}.lock.refcount"
85+
86+
monkeypatch.setattr(_fileio, "_soft_import", lambda *args, **kwargs: False)
87+
88+
_to_tsv(data, tsv_path)
89+
90+
assert tsv_path.exists()
91+
assert tsv_path.read_text().strip()
92+
assert not lock_path.exists()
93+
assert not refcount_path.exists()
94+
95+
7896
def test_contains_row_different_types():
7997
"""Test that _contains_row() can handle different dtypes without warning.
8098

0 commit comments

Comments
 (0)