Skip to content

Commit

Permalink
fix: Remove os-dependent pieces of schema validation (#2357)
Browse files Browse the repository at this point in the history
* Use pathlib to build the stem for the schema to use (version + type of schema).
   - c.f. python/cpython#65238
  • Loading branch information
kratsg authored Oct 24, 2023
1 parent 5093668 commit 6203a8f
Showing 1 changed file with 8 additions and 4 deletions.
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

0 comments on commit 6203a8f

Please sign in to comment.