Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backport): Remove os-dependent pieces of schema validation #2361

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/pyhf/schema/validator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numbers
from pathlib import Path
from typing import Mapping, Union

import jsonschema
Expand Down Expand Up @@ -70,12 +71,15 @@ def validate(

version = version or variables.SCHEMA_VERSION

schema = load_schema(f'{version}/{schema_name}')
schema = load_schema(str(Path(version).joinpath(schema_name)))

# note: trailing slash needed for RefResolver to resolve correctly
# note: trailing slash needed for RefResolver to resolve correctly and by
# design, pathlib strips trailing slashes. See ref below:
# * https://bugs.python.org/issue21039
# * https://github.com/python/cpython/issues/65238
resolver = jsonschema.RefResolver(
base_uri=f"file://{variables.schemas}/{version}/",
referrer=f"{schema_name}",
base_uri=f"{Path(variables.schemas).joinpath(version).as_uri()}/",
referrer=schema_name,
store=variables.SCHEMA_CACHE,
)

Expand Down