Codebase list python-taskflow / b2aac72
Add Adapt-to-new-jsonschema-versions.patch (Closes: #1016228). Thomas Goirand 1 year, 9 months ago
3 changed file(s) with 46 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
0 python-taskflow (4.6.4-3) UNRELEASED; urgency=medium
0 python-taskflow (4.6.4-3) unstable; urgency=medium
11
22 * Refreshed patches.
3 * Add Adapt-to-new-jsonschema-versions.patch (Closes: #1016228).
34
45 -- Thomas Goirand <zigo@debian.org> Sun, 31 Jul 2022 12:57:31 +0200
56
0 Author: Corey Bryant <corey.bryant@canonical.com>
1 Date: Tue, 02 Aug 2022 16:07:04 -0400
2 Description: Adapt to new jsonschema versions
3 This change provides fixes that were dectected by unit
4 test failures with new jsonschema (and py310).
5 .
6 The types argument has been removed in favor of providing a
7 type_checker to jsonschema.validators.extend:
8 https://github.com/python-jsonschema/jsonschema/issues/577
9 Closes-Bug: #1983412
10 Change-Id: I86f12b3d264320308e7f4841910fc21a6e8b3fa9
11 Origin: upstream, https://review.opendev.org/c/openstack/taskflow/+/851929
12 Last-Update: 2022-08-02
13
14 diff --git a/taskflow/utils/schema_utils.py b/taskflow/utils/schema_utils.py
15 index 8d7c216..758fa7b 100644
16 --- a/taskflow/utils/schema_utils.py
17 +++ b/taskflow/utils/schema_utils.py
18 @@ -17,12 +17,6 @@
19 import jsonschema
20 from jsonschema import exceptions as schema_exc
21
22 -# Special jsonschema validation types/adjustments.
23 -_SCHEMA_TYPES = {
24 - # See: https://github.com/Julian/jsonschema/issues/148
25 - 'array': (list, tuple),
26 -}
27 -
28
29 # Expose these types so that people don't have to import the same exceptions.
30 ValidationError = schema_exc.ValidationError
31 @@ -31,4 +25,10 @@
32
33 def schema_validate(data, schema):
34 """Validates given data using provided json schema."""
35 - jsonschema.validate(data, schema, types=_SCHEMA_TYPES)
36 + Validator = jsonschema.validators.validator_for(schema)
37 + # Special jsonschema validation types/adjustments.
38 + # See: https://github.com/Julian/jsonschema/issues/148
39 + type_checker = Validator.TYPE_CHECKER.redefine(
40 + "array", lambda checker, data: isinstance(data, (list, tuple)))
41 + TupleAllowingValidator = jsonschema.validators.extend(Validator, type_checker=type_checker)
42 + TupleAllowingValidator(schema).validate(data)
00 reproducible_build.patch
11 remove-bad-enum.py-calls.patch
2 Adapt-to-new-jsonschema-versions.patch