Skip to content

Commit 33e5984

Browse files
committed
fix: Annotate validator kwargs
1 parent 0cd18b9 commit 33e5984

File tree

1 file changed

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

1 file changed

+8
-1
lines changed

tools/schemacode/src/bidsschematools/utils.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@
1010

1111
TYPE_CHECKING = False
1212
if TYPE_CHECKING:
13-
from typing import Any
13+
from typing import Any, NotRequired, TypedDict
1414

15+
from jsonschema import FormatChecker
1516
from jsonschema.protocols import Validator as JsonschemaValidator
1617

18+
class ValidatorKwargs(TypedDict):
19+
"""Type for the keyword arguments used to create a JSON schema validator."""
20+
21+
format_checker: NotRequired[FormatChecker]
22+
1723

1824
def get_bundled_schema_path():
1925
"""Get the path to the schema directory.
@@ -140,5 +146,6 @@ def jsonschema_validator(
140146
# Ensure the schema is valid
141147
validator_cls.check_schema(schema)
142148

149+
validator_kwargs: ValidatorKwargs
143150
validator_kwargs = {"format_checker": validator_cls.FORMAT_CHECKER} if check_format else {}
144151
return validator_cls(schema, **validator_kwargs)

0 commit comments

Comments
 (0)