Skip to content

Commit 35b60f3

Browse files
committed
Release v2.3.0
1 parent 11ffd34 commit 35b60f3

3 files changed

Lines changed: 35 additions & 3 deletions

File tree

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
v2.3.0
2+
------
3+
4+
* Added by_relevance and best_match (#91)
5+
* Fixed ``format`` to allow adding formats for non-strings (#125)
6+
* Fixed the ``uri`` format to reject URI references (#131)
7+
18
v2.2.0
29
------
310

README.rst

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,33 @@ Features
4949
Release Notes
5050
-------------
5151

52-
``v2.2.0`` contains a minor speedup for the ``host-name`` format and a small
53-
change in draft 3's allowed types.
52+
``v2.3.0`` removes the (improper) limitation of ``format`` to strings. It also
53+
adds the `jsonschema.exceptions.best_match <https://python-jsonschema.readthedocs.org/en/latest/errors/#best-match-and-by-relevance>`_
54+
function which can be used to guess at the best matching single validation
55+
error for a given instance.
56+
57+
58+
.. code-block:: python
59+
60+
>>> from jsonschema.validators import Draft4Validator
61+
>>> from jsonschema.exceptions import best_match
62+
63+
>>> schema = {
64+
... "properties" : {
65+
... "foo" : {"type" : "string"},
66+
... "bar" : {"properties" : {"baz": {"type": "string"}}},
67+
... },
68+
... }
69+
>>> instance = {"foo" : 12, "bar": {"baz" : 19}}
70+
>>> print(best_match(Draft4Validator(schema).iter_errors(instance)).path)
71+
deque(['foo'])
72+
73+
74+
where the error closer to the top of the instance in ``foo`` was selected
75+
as being more relevant.
76+
77+
Also, URI references are now properly rejected by the URI format validator
78+
(i.e., it now only accepts full URIs, as defined in the specification).
5479

5580

5681
Running the Test Suite

jsonschema/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
)
2121

2222

23-
__version__ = "2.3.0-dev"
23+
__version__ = "2.3.0"
2424

2525

2626
# flake8: noqa

0 commit comments

Comments
 (0)