From ea2774ed54f3f2259141ed5f8a643cba6d8b5e32 Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Wed, 7 Dec 2022 10:01:11 -0800 Subject: [PATCH] downgrade validator to maintain behavior for correct draft for v1.0.0 HiFa --- src/pyhf/schema/validator.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pyhf/schema/validator.py b/src/pyhf/schema/validator.py index b46d866a6d..3860690a11 100644 --- a/src/pyhf/schema/validator.py +++ b/src/pyhf/schema/validator.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import numbers import jsonschema @@ -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 @@ -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: """ @@ -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