Skip to content

Commit 3fb9fed

Browse files
committed
Fix calculation of evaluated properties
1 parent 52fdebe commit 3fb9fed

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

jsonschema/_utils.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -302,18 +302,18 @@ def is_valid(errs_it):
302302
),
303303
)
304304

305-
for keyword in [
306-
"properties", "additionalProperties", "unevaluatedProperties",
307-
]:
308-
if keyword in schema:
309-
schema_value = schema[keyword]
310-
if validator.is_type(schema_value, "boolean") and schema_value:
311-
evaluated_keys += instance.keys()
312-
313-
elif validator.is_type(schema_value, "object"):
314-
for property in schema_value:
315-
if property in instance:
316-
evaluated_keys.append(property)
305+
properties = schema.get("properties")
306+
if validator.is_type(properties, "object"):
307+
evaluated_keys += properties.keys() & instance.keys()
308+
309+
for keyword in ["additionalProperties", "unevaluatedProperties"]:
310+
if (subschema := schema.get(keyword)) is None:
311+
continue
312+
evaluated_keys += (
313+
key
314+
for key, value in instance.items()
315+
if is_valid(validator.descend(value, subschema))
316+
)
317317

318318
if "patternProperties" in schema:
319319
for property in instance:

0 commit comments

Comments
 (0)