Skip to content

Commit 984ae37

Browse files
authored
enh: make sure existing layout.get_* are not bubbled in
1 parent ec95584 commit 984ae37

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

templateflow/api.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
from .conf import TF_LAYOUT, TF_S3_ROOT, TF_USE_DATALAD, requires_layout
99

10+
_layout_dir = tuple(
11+
item for item in dir(TF_LAYOUT) if item.startswith("get_")
12+
)
1013

1114
@requires_layout
1215
def ls(template, **kwargs):
@@ -253,7 +256,11 @@ def get_citations(template, bibtex=False):
253256
@requires_layout
254257
def __getattr__(key: str):
255258
key = key.replace("ls_", "get_")
256-
if key.startswith("get_") and key not in ("get_metadata", "get_citations"):
259+
if (
260+
key.startswith("get_")
261+
and key not in ("get_metadata", "get_citations")
262+
and key not in _layout_dir
263+
):
257264
return TF_LAYOUT.__getattr__(key)
258265

259266
# Spit out default message if we get this far

templateflow/tests/test_api.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,8 @@ def test_pybids_magic_get():
108108

109109
with pytest.raises(TypeError):
110110
api.ls_atlases("MNI152NLin6ASym")
111+
112+
# Existing layout.get_* should not be bubbled to the layout
113+
# (that means, raise an AttributeError instead of a BIDSEntityError)
114+
with pytest.raises(AttributeError):
115+
api.get_fieldmap

0 commit comments

Comments
 (0)