Skip to content

Commit aa814e2

Browse files
authored
🚨 Fix types for new Pydantic (#1131)
1 parent 79ef8d0 commit aa814e2

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

sqlmodel/main.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
from sqlalchemy.orm.instrumentation import is_instrumented
5353
from sqlalchemy.sql.schema import MetaData
5454
from sqlalchemy.sql.sqltypes import LargeBinary, Time, Uuid
55-
from typing_extensions import Literal, deprecated, get_origin
55+
from typing_extensions import Literal, TypeAlias, deprecated, get_origin
5656

5757
from ._compat import ( # type: ignore[attr-defined]
5858
IS_PYDANTIC_V2,
@@ -90,7 +90,12 @@
9090

9191
_T = TypeVar("_T")
9292
NoArgAnyCallable = Callable[[], Any]
93-
IncEx = Union[Set[int], Set[str], Dict[int, Any], Dict[str, Any], None]
93+
IncEx: TypeAlias = Union[
94+
Set[int],
95+
Set[str],
96+
Mapping[int, Union["IncEx", Literal[True]]],
97+
Mapping[str, Union["IncEx", Literal[True]]],
98+
]
9499
OnDeleteType = Literal["CASCADE", "SET NULL", "RESTRICT"]
95100

96101

@@ -858,8 +863,8 @@ def model_dump(
858863
self,
859864
*,
860865
mode: Union[Literal["json", "python"], str] = "python",
861-
include: IncEx = None,
862-
exclude: IncEx = None,
866+
include: Union[IncEx, None] = None,
867+
exclude: Union[IncEx, None] = None,
863868
context: Union[Dict[str, Any], None] = None,
864869
by_alias: bool = False,
865870
exclude_unset: bool = False,
@@ -908,8 +913,8 @@ def model_dump(
908913
def dict(
909914
self,
910915
*,
911-
include: IncEx = None,
912-
exclude: IncEx = None,
916+
include: Union[IncEx, None] = None,
917+
exclude: Union[IncEx, None] = None,
913918
by_alias: bool = False,
914919
exclude_unset: bool = False,
915920
exclude_defaults: bool = False,

0 commit comments

Comments
 (0)