summaryrefslogtreecommitdiff
path: root/jsonschema/_legacy_validators.py
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2021-08-18 18:15:07 +0100
committerJulian Berman <Julian@GrayVines.com>2021-08-18 18:15:07 +0100
commit00031cb043763842266877923552e40f0c8f36b5 (patch)
treea7ff84ca2244b7832f857f4715b324576ef3a604 /jsonschema/_legacy_validators.py
parenteb633b216bad1acb1a7739279c5ab83bdd63d7a1 (diff)
downloadjsonschema-00031cb043763842266877923552e40f0c8f36b5.tar.gz
Remove types_msg which implements really old draft-3 behavior.
Since then, types aren't objects, they're just strings. This just wastes time catching exceptions for newer drafts.
Diffstat (limited to 'jsonschema/_legacy_validators.py')
-rw-r--r--jsonschema/_legacy_validators.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/jsonschema/_legacy_validators.py b/jsonschema/_legacy_validators.py
index 3a8b499..50fdbc8 100644
--- a/jsonschema/_legacy_validators.py
+++ b/jsonschema/_legacy_validators.py
@@ -193,8 +193,15 @@ def type_draft3(validator, types, instance, schema):
if validator.is_type(instance, type):
return
else:
+ reprs = []
+ for type in types:
+ try:
+ reprs.append(repr(type["name"]))
+ except Exception:
+ reprs.append(repr(type))
yield ValidationError(
- _utils.types_msg(instance, types), context=all_errors,
+ f"{instance!r} is not of type {', '.join(reprs)}",
+ context=all_errors,
)