Skip to content

Commit 20123a8

Browse files
committed
Fix test_undefined_slot_raises: only swallow missing-parent-class errors
The broad except (ValueError, KeyError) from the NWB Container fix was also catching "No such slot: X" errors, causing test_undefined_slot_raises to stop raising as expected. Now re-raises any error whose message does not contain "No such class" — which covers missing slot references, invalid ranges, etc. Only errors from is_a pointing to a class outside the submitted schema (e.g. NWB's NWBContainer → Container) are silently tolerated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EXeTeJsXisxTRXay6EoBSQ
1 parent 6b40c7b commit 20123a8

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

neuro_ghost/ingest_linkml.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,13 @@ def parse_linkml(path: Path) -> dict[str, Any]:
252252

253253
try:
254254
induced_slots = sv.class_induced_slots(cls_name)
255-
except (ValueError, KeyError):
256-
# is_a points to a class outside this schema (e.g. NWB's "Container")
257-
# Fall back to directly-declared slots only.
255+
except (ValueError, KeyError) as exc:
256+
msg = str(exc)
257+
# Only tolerate "No such class" — that means is_a points outside
258+
# this schema (e.g. NWB's NWBContainer → Container). A missing
259+
# slot is a genuine schema error; re-raise so the caller sees it.
260+
if "No such class" not in msg:
261+
raise
258262
induced_slots = list(cls_def.attributes.values())
259263
for sname in (cls_def.slots or []):
260264
try:

0 commit comments

Comments
 (0)