|
4 | 4 | from __future__ import annotations
|
5 | 5 |
|
6 | 6 | from collections import defaultdict, deque
|
7 |
| -from collections.abc import Iterable |
| 7 | +from collections.abc import Iterable, Mapping |
8 | 8 | from pprint import pformat
|
9 | 9 | from textwrap import dedent, indent
|
10 | 10 | from typing import TYPE_CHECKING, Any
|
@@ -37,8 +37,8 @@ def __init__(
|
37 | 37 | cause: Exception | None = None,
|
38 | 38 | context=(),
|
39 | 39 | 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, |
42 | 42 | schema_path: Iterable[str | int] = (),
|
43 | 43 | parent: _Error | None = None,
|
44 | 44 | type_checker: _types.TypeChecker | _utils.Unset = _unset,
|
@@ -160,11 +160,8 @@ def _contents(self):
|
160 | 160 | return dict((attr, getattr(self, attr)) for attr in attrs)
|
161 | 161 |
|
162 | 162 | def _matches_type(self) -> bool:
|
163 |
| - if isinstance(self.schema, _utils.Unset): |
164 |
| - return False |
165 |
| - |
166 | 163 | try:
|
167 |
| - expected = self.schema["type"] |
| 164 | + expected = self.schema["type"] # type: ignore[index] # We crash if it's not a dict |
168 | 165 | except (KeyError, TypeError):
|
169 | 166 | return False
|
170 | 167 |
|
|
0 commit comments