Skip to content

Commit f06a665

Browse files
committed
rf: Defer jsonschema import until validation
1 parent f325c04 commit f06a665

File tree

1 file changed

+8
-2
lines changed
  • tools/schemacode/src/bidsschematools

1 file changed

+8
-2
lines changed

tools/schemacode/src/bidsschematools/schema.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from copy import deepcopy
99
from functools import lru_cache
1010

11-
from jsonschema import ValidationError, validate
12-
1311
from . import __bids_version__, __version__, data, utils
1412
from .types import Namespace
1513

@@ -292,6 +290,14 @@ def filter_schema(schema, **kwargs):
292290

293291
def validate_schema(schema: Namespace):
294292
"""Validate a schema against the BIDS metaschema."""
293+
try:
294+
from jsonschema import ValidationError, validate
295+
except ImportError as e:
296+
raise RuntimeError(
297+
"The `jsonschema` package is required to validate schemas. "
298+
"Please install it with `pip install jsonschema`."
299+
) from e
300+
295301
from .data import load
296302

297303
metaschema = json.loads(load.readable("metaschema.json").read_text())

0 commit comments

Comments
 (0)