Skip to content

Commit 151dbfb

Browse files
committed
Switch path.walk to os.walk for py311
- Enables use of `finds_bids_datasets` in py311. - `root` in `_indexing.py` is initially passed as original type, with walked `dirpath` typecasted as Path - Removed error for <py312 in throughout codebase + testing
1 parent 3c1763b commit 151dbfb

4 files changed

Lines changed: 3 additions & 18 deletions

File tree

bids2table/__main__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ def _index_command(args: argparse.Namespace):
152152

153153

154154
def _find_command(args: argparse.Namespace):
155-
if sys.version_info < (3, 12):
156-
_logger.error("bids2table find requires Python 3.12 or higher.")
157-
sys.exit(1)
158-
159155
_check_path(args.root)
160156

161157
for dataset in b2t2.find_bids_datasets(

bids2table/_indexing.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import enum
88
import fnmatch
99
import importlib.metadata
10+
import os
1011
import re
11-
import sys
1212
from concurrent.futures import Executor, ProcessPoolExecutor
1313
from functools import partial
1414
from typing import Any, Callable, Generator, Iterable, Sequence
@@ -143,21 +143,13 @@ def find_bids_datasets(
143143
144144
Yields:
145145
Root paths of all BIDS datasets under `root`.
146-
147-
.. note::
148-
Requires Python >= 3.12.
149146
"""
150-
if sys.version_info < (3, 12):
151-
raise RuntimeError("find_bids_datasets requires Python 3.12 or higher.")
152-
153-
root = as_path(root)
154-
155147
dir_count = 0
156148
ds_count = 0
157149

158-
# NOTE: Path.walk was introduced in 3.12. Otherwise, could use an older python.
159-
for dirpath, dirnames, _ in root.walk(follow_symlinks=follow_symlinks):
150+
for dirpath, dirnames, _ in os.walk(root, followlinks=follow_symlinks):
160151
dir_count += 1
152+
dirpath = as_path(dirpath)
161153

162154
if _is_bids_dataset(dirpath):
163155
ds_count += 1

tests/test_indexing.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import logging
2-
import sys
32
from pathlib import Path
43

54
import pyarrow as pa
@@ -25,7 +24,6 @@ def test_get_column_names():
2524
assert BIDSColumn.dataset == "dataset"
2625

2726

28-
@pytest.mark.skipif(sys.version_info < (3, 12), reason="Python < 3.12.")
2927
def test_find_bids_datasets():
3028
datasets = sorted(indexing.find_bids_datasets(BIDS_EXAMPLES, log_frequency=100))
3129
expected_datasets = sorted(

tests/test_main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def test_main_index(cmd: str, output: str | None, tmp_path: Path):
4343
assert (tmp_path / output).exists()
4444

4545

46-
@pytest.mark.skipif(sys.version_info < (3, 12), reason="Python < 3.12.")
4746
@pytest.mark.parametrize("cmd", ["find {examples}"])
4847
def test_main_find(cmd: str):
4948
cmd_fmt = cmd.format(examples=BIDS_EXAMPLES)

0 commit comments

Comments
 (0)