Skip to content

Commit cd270e4

Browse files
authored
Fix _IncEx type alias to be compatible with mypy (#1537)
1 parent 2419981 commit cd270e4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

python/pydantic_core/_pydantic_core.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,9 @@ class SchemaValidator:
253253
`None` if the schema has no default value, otherwise a [`Some`][pydantic_core.Some] containing the default.
254254
"""
255255

256-
_IncEx: TypeAlias = set[int] | set[str] | Mapping[int, _IncEx | Literal[True]] | Mapping[str, _IncEx | Literal[True]]
256+
# In reality, `bool` should be replaced by `Literal[True]` but mypy fails to correctly apply bidirectional type inference
257+
# (e.g. when using `{'a': {'b': True}}`).
258+
_IncEx: TypeAlias = set[int] | set[str] | Mapping[int, _IncEx | bool] | Mapping[str, _IncEx | bool]
257259

258260
@final
259261
class SchemaSerializer:

0 commit comments

Comments
 (0)