Skip to content

Commit

Permalink
Add typing and check to _Error._matches_type
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielNoord committed Dec 22, 2022
1 parent e2c3a06 commit a19b564
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions jsonschema/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,15 @@ def _contents(self):
)
return dict((attr, getattr(self, attr)) for attr in attrs)

def _matches_type(self):
def _matches_type(self) -> bool:
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

if isinstance(self._type_checker, _utils.Unset):
return False

if isinstance(expected, str):
return self._type_checker.is_type(self.instance, expected)

Expand Down

0 comments on commit a19b564

Please sign in to comment.