From 6a16fcd6664ef2f8fe8e640884ad8d17f1baf213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Tue, 29 Nov 2022 00:05:34 +0100 Subject: [PATCH] Initial review --- jsonschema/exceptions.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/jsonschema/exceptions.py b/jsonschema/exceptions.py index ed792b0a..f6a3b414 100644 --- a/jsonschema/exceptions.py +++ b/jsonschema/exceptions.py @@ -4,7 +4,7 @@ from __future__ import annotations from collections import defaultdict, deque -from collections.abc import Iterable +from collections.abc import Iterable, Mapping from pprint import pformat from textwrap import dedent, indent from typing import TYPE_CHECKING, Any @@ -37,8 +37,8 @@ def __init__( cause: Exception | None = None, context=(), validator_value=_unset, - instance: dict[str, Any] | _utils.Unset = _unset, - schema: dict[str, Any] | _utils.Unset = _unset, + instance: Any = _unset, + schema: Mapping[str, Any] | bool | _utils.Unset = _unset, schema_path: Iterable[str | int] = (), parent: _Error | None = None, type_checker: _types.TypeChecker | _utils.Unset = _unset, @@ -160,11 +160,8 @@ def _contents(self): return dict((attr, getattr(self, attr)) for attr in attrs) def _matches_type(self) -> bool: - if isinstance(self.schema, _utils.Unset): - return False - try: - expected = self.schema["type"] + expected = self.schema["type"] # type: ignore[index] # We crash if it's not a dict except (KeyError, TypeError): return False