Skip to content

Commit

Permalink
downgrade validator to maintain behavior for correct draft for v1.0.0…
Browse files Browse the repository at this point in the history
… HiFa
  • Loading branch information
kratsg committed Dec 7, 2022
1 parent e159409 commit ea2774e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/pyhf/schema/validator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import numbers

import jsonschema
Expand All @@ -7,7 +9,6 @@
from pyhf import tensor
from pyhf.schema import variables
from pyhf.schema.loader import load_schema
from typing import Union
from pyhf.typing import Workspace, Model, Measurement, PatchSet
from typing import Any

Expand Down Expand Up @@ -41,10 +42,10 @@ def _is_number_or_tensor_subtype(


def validate(
spec: Union[Workspace, Model, Measurement, PatchSet],
spec: Workspace | Model | Measurement | PatchSet,
schema_name: str,
*,
version: Union[str, None] = None,
version: str | None = None,
allow_tensors: bool = True,
) -> None:
"""
Expand Down Expand Up @@ -95,6 +96,10 @@ def validate(

Validator = jsonschema.Draft202012Validator

# downgrade Validator for v1.0.0
if version == '1.0.0':
Validator = jsonschema.Draft6Validator # type: ignore[assignment]

if allow_tensors:
type_checker = Validator.TYPE_CHECKER.redefine(
"array", _is_array_or_tensor
Expand Down

0 comments on commit ea2774e

Please sign in to comment.