Skip to content

Commit 9aee436

Browse files
committed
Add typing and fix a type issue in _Error._matches_type
1 parent be52fcf commit 9aee436

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

jsonschema/exceptions.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,18 @@ def _contents(self):
155155
)
156156
return dict((attr, getattr(self, attr)) for attr in attrs)
157157

158-
def _matches_type(self):
158+
def _matches_type(self) -> bool:
159+
if isinstance(self.schema, _utils.Unset):
160+
return False
161+
159162
try:
160163
expected = self.schema["type"]
161164
except (KeyError, TypeError):
162165
return False
163166

167+
if isinstance(self._type_checker, _utils.Unset):
168+
return False
169+
164170
if isinstance(expected, str):
165171
return self._type_checker.is_type(self.instance, expected)
166172

0 commit comments

Comments
 (0)