From e868bfeddee255ff55ad40345d4b6e8c3519b577 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 28 Nov 2022 12:05:07 -0500 Subject: [PATCH] Durations without trailing units aren't valid durations. Refs: json-schema-org/JSON-Schema-Test-Suite#606 --- CHANGELOG.rst | 9 +++++++++ jsonschema/_format.py | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d3352bdd..8df86609 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,12 @@ +v4.17.2 +======= + +* Empty strings are not valid relative JSON Pointers (aren't valid under the + RJP format). +* Durations without (trailing) units are not valid durations (aren't + valid under the duration format). This involves changing the dependency + used for validating durations (from ``isoduration`` to ``isodate``). + v4.17.1 ======= diff --git a/jsonschema/_format.py b/jsonschema/_format.py index 5e483269..5ec97977 100644 --- a/jsonschema/_format.py +++ b/jsonschema/_format.py @@ -501,7 +501,9 @@ def is_uri_template(instance: object) -> bool: def is_duration(instance: object) -> bool: if not isinstance(instance, str): return True - return bool(isoduration.parse_duration(instance)) + isoduration.parse_duration(instance) + # FIXME: See bolsote/isoduration#25 and bolsote/isoduration#21 + return instance.endswith(tuple("DMYWHMS")) @_checks_drafts(