Skip to content

Commit 6a16fcd

Browse files
committed
Initial review
1 parent c4a758c commit 6a16fcd

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

jsonschema/exceptions.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from __future__ import annotations
55

66
from collections import defaultdict, deque
7-
from collections.abc import Iterable
7+
from collections.abc import Iterable, Mapping
88
from pprint import pformat
99
from textwrap import dedent, indent
1010
from typing import TYPE_CHECKING, Any
@@ -37,8 +37,8 @@ def __init__(
3737
cause: Exception | None = None,
3838
context=(),
3939
validator_value=_unset,
40-
instance: dict[str, Any] | _utils.Unset = _unset,
41-
schema: dict[str, Any] | _utils.Unset = _unset,
40+
instance: Any = _unset,
41+
schema: Mapping[str, Any] | bool | _utils.Unset = _unset,
4242
schema_path: Iterable[str | int] = (),
4343
parent: _Error | None = None,
4444
type_checker: _types.TypeChecker | _utils.Unset = _unset,
@@ -160,11 +160,8 @@ def _contents(self):
160160
return dict((attr, getattr(self, attr)) for attr in attrs)
161161

162162
def _matches_type(self) -> bool:
163-
if isinstance(self.schema, _utils.Unset):
164-
return False
165-
166163
try:
167-
expected = self.schema["type"]
164+
expected = self.schema["type"] # type: ignore[index] # We crash if it's not a dict
168165
except (KeyError, TypeError):
169166
return False
170167

0 commit comments

Comments
 (0)