Skip to content

Commit efa28c6

Browse files
committed
Add typing and check to _Error._matches_type
1 parent e2c3a06 commit efa28c6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

jsonschema/exceptions.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,16 @@ def _contents(self):
154154
)
155155
return dict((attr, getattr(self, attr)) for attr in attrs)
156156

157-
def _matches_type(self):
157+
def _matches_type(self) -> bool:
158158
try:
159-
expected = self.schema["type"]
159+
# We ignore this as we want to simply crash if this happens
160+
expected = self.schema["type"] # type: ignore[index]
160161
except (KeyError, TypeError):
161162
return False
162163

164+
if isinstance(self._type_checker, _utils.Unset):
165+
return False
166+
163167
if isinstance(expected, str):
164168
return self._type_checker.is_type(self.instance, expected)
165169

0 commit comments

Comments
 (0)