Skip to content

Commit 8e678c0

Browse files
committed
Fix CloudPath import
- Use _pathlib.CloudPath instead of cloudpathlib.CloudPath. The import here already has a bunch of logic baked in to check and fallback the pathtype if cloudpathlib isn't available. - For the conditional logic, make use of the cloudpathlib_is_available function to step into check - TODO: Add tests to make sure cloudpathlib functionality is working as expected
1 parent f3d111c commit 8e678c0

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

bids2table/_indexing.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from typing import Any, Callable, Generator, Iterable, Sequence
1616

1717
import pyarrow as pa
18-
from cloudpathlib import CloudPath
1918
from tqdm import tqdm
2019

2120
from ._entities import (
@@ -24,7 +23,7 @@
2423
validate_bids_entities,
2524
)
2625
from ._logging import setup_logger
27-
from ._pathlib import PathT, as_path
26+
from ._pathlib import CloudPath, PathT, as_path, cloudpathlib_is_available
2827

2928
_BIDS_SUBJECT_DIR_PATTERN = re.compile(r"sub-[a-zA-Z0-9]+")
3029

@@ -404,7 +403,7 @@ def _index_bids_subject_dir(
404403

405404
records = []
406405
# Use built-in rglob methods for CloudPath and py3.13+
407-
if isinstance(path, CloudPath):
406+
if cloudpathlib_is_available() and isinstance(path, CloudPath):
408407
paths = map(as_path, path.rglob("sub-*"))
409408
elif sys.version_info >= (3, 13):
410409
paths = map(as_path, path.rglob("sub-*", recurse_symlinks=True))

0 commit comments

Comments
 (0)