Skip to content

Commit

Permalink
Merge pull request #227 from callumforrester/json-version
Browse files Browse the repository at this point in the history
Use importlib.metadata to determine jsonschema version
  • Loading branch information
danielballan authored Oct 11, 2022
2 parents 4c6df2c + 87b810d commit 772ae3c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions event_model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import inspect
import os
from pkg_resources import resource_filename as rs_fn
from importlib.metadata import version
import threading
import time as ttime
import types
Expand Down Expand Up @@ -1531,11 +1532,10 @@ class MismatchedDataKeys(InvalidData):
with open(rs_fn('event_model', filename)) as fin:
schemas[name] = json.load(fin)


# We pin jsonschema >=3.0.0 in requirements.txt but due to pip's dependency
# resolution it is easy to end up with an environment where that pin is not
# respected. Thus, we maintain best-effort support for 2.x.
if LooseVersion(jsonschema.__version__) >= LooseVersion("3.0.0"):
if LooseVersion(version("jsonschema")) >= LooseVersion("3.0.0"):
def _is_array(checker, instance):
return (
jsonschema.validators.Draft7Validator.TYPE_CHECKER.is_type(instance, 'array') or
Expand Down

0 comments on commit 772ae3c

Please sign in to comment.