Skip to content

Commit

Permalink
Ignore additionalItems when items isn't present on 2019.
Browse files Browse the repository at this point in the history
This is specified behavior, see json-schema-org/JSON-Schema-Test-Suite#643.
  • Loading branch information
Julian committed Mar 14, 2023
1 parent f953e97 commit 8bdec06
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Expand Up @@ -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
=======
Expand Down
6 changes: 3 additions & 3 deletions jsonschema/_legacy_validators.py
Expand Up @@ -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(
Expand All @@ -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"])))
Expand Down

0 comments on commit 8bdec06

Please sign in to comment.