diff options
author | Julian Berman <Julian@GrayVines.com> | 2023-03-14 17:24:28 -0400 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2023-03-14 17:25:48 -0400 |
commit | 8bdec0635103833dcb90fdef28d2ca070b6c97a3 (patch) | |
tree | 0fe5b1eab83f6f2b9549a0cba1780896e684487d | |
parent | f953e977ed555f3d0db1092d06def688a3db2b16 (diff) | |
download | jsonschema-8bdec0635103833dcb90fdef28d2ca070b6c97a3.tar.gz |
Ignore additionalItems when items isn't present on 2019.
This is specified behavior, see json-schema-org/JSON-Schema-Test-Suite#643.
-rw-r--r-- | CHANGELOG.rst | 1 | ||||
-rw-r--r-- | jsonschema/_legacy_validators.py | 6 |
2 files changed, 4 insertions, 3 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2d2f22e..63c89cc 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,7 @@ v4.18.0 Please file issues on the ``referencing`` tracker if there is functionality missing from it, or here on the ``jsonschema`` issue tracker if you have issues with existing code not functioning the same, or with figuring out how to change it to use ``referencing``. * Support for Python 3.7 has been dropped, as it is nearing end-of-life. This should not be a "visible" change in the sense that ``requires-python`` has been updated, so users using 3.7 should still receive ``v4.17.3`` when installing the library. +* On draft 2019-09, ``unevaluatedItems`` now properly does *not* consider items to be evaluated by an ``additionalItems`` schema if ``items`` is missing from the schema, as the specification says in this case that ``additionalItems`` must be completely ignored. v4.17.3 ======= diff --git a/jsonschema/_legacy_validators.py b/jsonschema/_legacy_validators.py index aebf1b9..9a211f3 100644 --- a/jsonschema/_legacy_validators.py +++ b/jsonschema/_legacy_validators.py @@ -231,9 +231,6 @@ def find_evaluated_item_indexes_by_schema(validator, instance, schema): return [] evaluated_indexes = [] - if "additionalItems" in schema: - return list(range(0, len(instance))) - if "$ref" in schema: resolved = validator._resolver.lookup(schema["$ref"]) evaluated_indexes.extend( @@ -248,6 +245,9 @@ def find_evaluated_item_indexes_by_schema(validator, instance, schema): ) if "items" in schema: + if "additionalItems" in schema: + return list(range(0, len(instance))) + if validator.is_type(schema["items"], "object"): return list(range(0, len(instance))) evaluated_indexes += list(range(0, len(schema["items"]))) |