Skip to content

Commit ef0669e

Browse files
committed
Use jsonschema >= 4.0
1 parent 561a549 commit ef0669e

File tree

8 files changed

+87
-73
lines changed

8 files changed

+87
-73
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
#### 0.21.0 - 2021-10-03
4+
- reduced filtering for object keys (#88)
5+
- updated to `jsonschema >= 4.0.0` (#89);
6+
though support for `Draft 2019-09` and `2020-12` will take longer
7+
38
#### 0.20.1 - 2021-06-03
49
- improved handling for fractional `multipleOf` values
510

deps/check.txt

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@
44
#
55
# pip-compile --output-file=deps/check.txt deps/check.in
66
#
7-
appdirs==1.4.4
8-
# via black
97
attrs==21.2.0
108
# via flake8-bugbear
119
autoflake==1.4
1210
# via shed
1311
bandit==1.7.0
1412
# via flake8-bandit
15-
black==21.6b0
13+
black==21.9b0
1614
# via shed
17-
click==7.1.2
18-
# via
19-
# black
20-
# pybetter
21-
# pyemojify
15+
click==8.0.1
16+
# via black
2217
colorama==0.4.4
23-
# via bandit
18+
# via
19+
# bandit
20+
# click
2421
com2ann==0.1.1
2522
# via -r deps/check.in
2623
flake8==3.9.2
@@ -36,11 +33,11 @@ flake8==3.9.2
3633
# pep8-naming
3734
flake8-bandit==2.1.2
3835
# via -r deps/check.in
39-
flake8-bugbear==21.4.3
36+
flake8-bugbear==21.9.2
4037
# via -r deps/check.in
4138
flake8-builtins==1.5.3
4239
# via -r deps/check.in
43-
flake8-comprehensions==3.5.0
40+
flake8-comprehensions==3.6.1
4441
# via -r deps/check.in
4542
flake8-docstrings==1.6.0
4643
# via -r deps/check.in
@@ -52,19 +49,18 @@ flake8-print==4.0.0
5249
# via -r deps/check.in
5350
gitdb==4.0.7
5451
# via gitpython
55-
gitpython==3.1.18
52+
gitpython==3.1.24
5653
# via bandit
57-
importlib-metadata==4.6.1
54+
importlib-metadata==4.8.1
5855
# via
56+
# click
5957
# flake8
6058
# flake8-comprehensions
6159
# stevedore
62-
isort==5.9.2
60+
isort==5.9.3
61+
# via shed
62+
libcst==0.3.21
6363
# via shed
64-
libcst==0.3.19
65-
# via
66-
# pybetter
67-
# shed
6864
mccabe==0.6.1
6965
# via flake8
7066
mypy==0.910
@@ -74,38 +70,34 @@ mypy-extensions==0.4.3
7470
# black
7571
# mypy
7672
# typing-inspect
77-
pathspec==0.8.1
73+
pathspec==0.9.0
7874
# via black
7975
pbr==5.6.0
8076
# via stevedore
81-
pep8-naming==0.12.0
77+
pep8-naming==0.12.1
8278
# via -r deps/check.in
83-
pybetter==0.3.7
84-
# via shed
79+
platformdirs==2.4.0
80+
# via black
8581
pycodestyle==2.7.0
8682
# via
8783
# flake8
8884
# flake8-bandit
8985
# flake8-print
9086
pydocstyle==6.1.1
9187
# via flake8-docstrings
92-
pyemojify==0.2.0
93-
# via pybetter
9488
pyflakes==2.3.1
9589
# via
9690
# autoflake
9791
# flake8
98-
pygments==2.9.0
99-
# via pybetter
100-
pyupgrade==2.20.0
92+
pyupgrade==2.29.0
10193
# via shed
10294
pyyaml==5.4.1
10395
# via
10496
# bandit
10597
# libcst
106-
regex==2021.7.6
98+
regex==2021.9.30
10799
# via black
108-
shed==0.3.6
100+
shed==0.5.0
109101
# via -r deps/check.in
110102
six==1.16.0
111103
# via
@@ -115,19 +107,19 @@ smmap==4.0.0
115107
# via gitdb
116108
snowballstemmer==2.1.0
117109
# via pydocstyle
118-
stevedore==3.3.0
110+
stevedore==3.4.0
119111
# via bandit
120112
tokenize-rt==4.1.0
121113
# via pyupgrade
122114
toml==0.10.2
123-
# via
124-
# black
125-
# mypy
115+
# via mypy
116+
tomli==1.2.1
117+
# via black
126118
typed-ast==1.4.3
127119
# via
128120
# black
129121
# mypy
130-
typing-extensions==3.10.0.0
122+
typing-extensions==3.10.0.2
131123
# via
132124
# black
133125
# gitpython
@@ -137,5 +129,5 @@ typing-extensions==3.10.0.0
137129
# typing-inspect
138130
typing-inspect==0.7.1
139131
# via libcst
140-
zipp==3.5.0
132+
zipp==3.6.0
141133
# via importlib-metadata

deps/test.txt

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,47 @@
44
#
55
# pip-compile --output-file=deps/test.txt deps/test.in setup.py
66
#
7+
arrow==1.2.0
8+
# via isoduration
79
atomicwrites==1.4.0
810
# via pytest
911
attrs==21.2.0
1012
# via
1113
# hypothesis
1214
# jsonschema
1315
# pytest
16+
cached-property==1.5.2
17+
# via fqdn
1418
colorama==0.4.4
1519
# via pytest
16-
coverage==5.5
20+
coverage==6.0
1721
# via pytest-cov
1822
execnet==1.9.0
1923
# via pytest-xdist
20-
hypothesis==6.14.1
24+
fqdn==1.5.1
25+
# via jsonschema
26+
hypothesis==6.23.1
2127
# via hypothesis-jsonschema (setup.py)
2228
idna==3.2
2329
# via jsonschema
24-
importlib-metadata==4.6.1
30+
importlib-metadata==4.8.1
2531
# via
2632
# jsonschema
2733
# pluggy
2834
# pytest
2935
iniconfig==1.1.1
3036
# via pytest
37+
isoduration==20.11.0
38+
# via jsonschema
3139
jsonpointer==2.1
3240
# via jsonschema
33-
jsonschema[format]==3.2.0
41+
jsonschema[format]==4.0.1
3442
# via
3543
# -r deps/test.in
3644
# hypothesis-jsonschema (setup.py)
3745
packaging==21.0
3846
# via pytest
39-
pluggy==0.13.1
47+
pluggy==1.0.0
4048
# via pytest
4149
py==1.10.0
4250
# via
@@ -46,7 +54,7 @@ pyparsing==2.4.7
4654
# via packaging
4755
pyrsistent==0.18.0
4856
# via jsonschema
49-
pytest==6.2.4
57+
pytest==6.2.5
5058
# via
5159
# -r deps/test.in
5260
# pytest-cov
@@ -56,26 +64,31 @@ pytest-cov==2.12.1
5664
# via -r deps/test.in
5765
pytest-forked==1.3.0
5866
# via pytest-xdist
59-
pytest-xdist==2.3.0
67+
pytest-xdist==2.4.0
6068
# via -r deps/test.in
69+
python-dateutil==2.8.2
70+
# via arrow
71+
rfc3339-validator==0.1.4
72+
# via jsonschema
6173
rfc3987==1.3.8
6274
# via jsonschema
6375
six==1.16.0
64-
# via jsonschema
76+
# via
77+
# python-dateutil
78+
# rfc3339-validator
6579
sortedcontainers==2.4.0
6680
# via hypothesis
67-
strict-rfc3339==0.7
68-
# via jsonschema
6981
toml==0.10.2
7082
# via
7183
# pytest
7284
# pytest-cov
73-
typing-extensions==3.10.0.0
74-
# via importlib-metadata
85+
typing-extensions==3.10.0.2
86+
# via
87+
# arrow
88+
# importlib-metadata
89+
uri-template==1.1.0
90+
# via jsonschema
7591
webcolors==1.11.1
7692
# via jsonschema
77-
zipp==3.5.0
93+
zipp==3.6.0
7894
# via importlib-metadata
79-
80-
# The following packages are considered to be unsafe in a requirements file:
81-
# setuptools

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def local_file(name: str) -> str:
2121
name="hypothesis-jsonschema",
2222
version=__version__,
2323
author="Zac Hatfield-Dodds",
24-
author_email="zac@hypothesis.works",
24+
author_email="zac@zhd.dev",
2525
packages=setuptools.find_packages(SOURCE),
2626
package_dir={"": SOURCE},
2727
package_data={"": ["py.typed"]},
@@ -30,7 +30,7 @@ def local_file(name: str) -> str:
3030
license="MPL 2.0",
3131
description="Generate test data from JSON schemata with Hypothesis",
3232
zip_safe=False,
33-
install_requires=["hypothesis>=5.3.0", "jsonschema>=3.0.2"],
33+
install_requires=["hypothesis>=5.3.0", "jsonschema>=4.0.0"],
3434
python_requires=">=3.6",
3535
classifiers=[
3636
"Development Status :: 4 - Beta",
@@ -42,6 +42,7 @@ def local_file(name: str) -> str:
4242
"Programming Language :: Python :: 3.6",
4343
"Programming Language :: Python :: 3.7",
4444
"Programming Language :: Python :: 3.8",
45+
"Programming Language :: Python :: 3.9",
4546
"Topic :: Education :: Testing",
4647
"Topic :: Software Development :: Testing",
4748
"Typing :: Typed",

src/hypothesis_jsonschema/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The only public API is `from_schema`; check the docstring for details.
44
"""
55

6-
__version__ = "0.20.1"
6+
__version__ = "0.21.0"
77
__all__ = ["from_schema"]
88

99
from ._from_schema import from_schema

src/hypothesis_jsonschema/_canonicalise.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
most things by construction instead of by filtering. That's the difference
1313
between "I'd like it to be faster" and "doesn't finish at all".
1414
"""
15+
import contextlib
1516
import itertools
1617
import json
1718
import math
@@ -69,13 +70,15 @@ def next_down(val: float) -> float:
6970

7071

7172
def _get_validator_class(schema: Schema) -> JSONSchemaValidator:
72-
try:
73+
with contextlib.suppress(jsonschema.exceptions.SchemaError):
7374
validator = jsonschema.validators.validator_for(schema)
7475
validator.check_schema(schema)
75-
except jsonschema.exceptions.SchemaError:
76-
validator = jsonschema.Draft4Validator
77-
validator.check_schema(schema)
78-
return validator
76+
return validator
77+
with contextlib.suppress(jsonschema.exceptions.SchemaError):
78+
jsonschema.Draft7Validator.check_schema(schema)
79+
return jsonschema.Draft7Validator
80+
jsonschema.Draft4Validator.check_schema(schema)
81+
return jsonschema.Draft4Validator
7982

8083

8184
def make_validator(schema: Schema) -> JSONSchemaValidator:

tests/test_canonicalise.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,12 @@ def test_canonicalises_to_equivalent_fixpoint(schema_strategy, data):
3838
assume(False)
3939
instance = data.draw(JSON_STRATEGY | strat, label="instance")
4040
assert is_valid(instance, schema) == is_valid(instance, cc)
41-
jsonschema.validators.validator_for(schema).check_schema(schema)
41+
make_validator(schema)
4242

4343

4444
@pytest.mark.parametrize(
4545
"schema, examples",
46-
[
47-
# See https://github.com/Julian/jsonschema/pull/746
48-
pytest.param(
49-
{"type": "integer", "multipleOf": 0.75},
50-
[1.5e308],
51-
marks=pytest.mark.xfail(raises=OverflowError),
52-
),
53-
],
46+
[({"type": "integer", "multipleOf": 0.75}, [1.5e308])],
5447
)
5548
def test_canonicalises_to_equivalent_fixpoint_examples(schema, examples):
5649
"""Check that an object drawn from an arbitrary schema is valid.

0 commit comments

Comments
 (0)