From 1583370bc1cba5adf1da3db090f3711f2e90213c Mon Sep 17 00:00:00 2001 From: Ilya Konstantinov Date: Mon, 27 Mar 2023 21:23:56 -0400 Subject: Do not validate for unevaluatedProperties --- jsonschema/_utils.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'jsonschema') diff --git a/jsonschema/_utils.py b/jsonschema/_utils.py index 3f1a440..223f2df 100644 --- a/jsonschema/_utils.py +++ b/jsonschema/_utils.py @@ -275,26 +275,19 @@ def find_evaluated_property_keys_by_schema(validator, instance, schema): "properties", "additionalProperties", "unevaluatedProperties", ]: if keyword in schema: - if validator.is_type(schema[keyword], "boolean"): + if validator.is_type(schema[keyword], "boolean") and schema[keyword]: for property, value in instance.items(): - if validator.evolve(schema=schema[keyword]).is_valid( - {property: value}, - ): - evaluated_keys.append(property) + evaluated_keys.append(property) - if validator.is_type(schema[keyword], "object"): + elif validator.is_type(schema[keyword], "object"): for property, subschema in schema[keyword].items(): - if property in instance and validator.evolve( - schema=subschema, - ).is_valid(instance[property]): + if property in instance: evaluated_keys.append(property) if "patternProperties" in schema: for property, value in instance.items(): - for pattern, _ in schema["patternProperties"].items(): - if re.search(pattern, property) and validator.evolve( - schema=schema["patternProperties"], - ).is_valid({property: value}): + for pattern in schema["patternProperties"]: + if re.search(pattern, property): evaluated_keys.append(property) if "dependentSchemas" in schema: -- cgit v1.2.1