🚨 Fix types for new Pydantic (#1131)

This commit is contained in:
Sebastián Ramírez 2024-10-07 23:21:59 +02:00 committed by GitHub
parent 79ef8d0675
commit aa814e24bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -52,7 +52,7 @@ from sqlalchemy.orm.decl_api import DeclarativeMeta
from sqlalchemy.orm.instrumentation import is_instrumented from sqlalchemy.orm.instrumentation import is_instrumented
from sqlalchemy.sql.schema import MetaData from sqlalchemy.sql.schema import MetaData
from sqlalchemy.sql.sqltypes import LargeBinary, Time, Uuid from sqlalchemy.sql.sqltypes import LargeBinary, Time, Uuid
from typing_extensions import Literal, deprecated, get_origin from typing_extensions import Literal, TypeAlias, deprecated, get_origin
from ._compat import ( # type: ignore[attr-defined] from ._compat import ( # type: ignore[attr-defined]
IS_PYDANTIC_V2, IS_PYDANTIC_V2,
@ -90,7 +90,12 @@ if TYPE_CHECKING:
_T = TypeVar("_T") _T = TypeVar("_T")
NoArgAnyCallable = Callable[[], Any] NoArgAnyCallable = Callable[[], Any]
IncEx = Union[Set[int], Set[str], Dict[int, Any], Dict[str, Any], None] IncEx: TypeAlias = Union[
Set[int],
Set[str],
Mapping[int, Union["IncEx", Literal[True]]],
Mapping[str, Union["IncEx", Literal[True]]],
]
OnDeleteType = Literal["CASCADE", "SET NULL", "RESTRICT"] OnDeleteType = Literal["CASCADE", "SET NULL", "RESTRICT"]
@ -858,8 +863,8 @@ class SQLModel(BaseModel, metaclass=SQLModelMetaclass, registry=default_registry
self, self,
*, *,
mode: Union[Literal["json", "python"], str] = "python", mode: Union[Literal["json", "python"], str] = "python",
include: IncEx = None, include: Union[IncEx, None] = None,
exclude: IncEx = None, exclude: Union[IncEx, None] = None,
context: Union[Dict[str, Any], None] = None, context: Union[Dict[str, Any], None] = None,
by_alias: bool = False, by_alias: bool = False,
exclude_unset: bool = False, exclude_unset: bool = False,
@ -908,8 +913,8 @@ class SQLModel(BaseModel, metaclass=SQLModelMetaclass, registry=default_registry
def dict( def dict(
self, self,
*, *,
include: IncEx = None, include: Union[IncEx, None] = None,
exclude: IncEx = None, exclude: Union[IncEx, None] = None,
by_alias: bool = False, by_alias: bool = False,
exclude_unset: bool = False, exclude_unset: bool = False,
exclude_defaults: bool = False, exclude_defaults: bool = False,