Skip to content
Merged
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
if: matrix.pydantic-version == 'pydantic-v2'
run: uv pip install --upgrade "pydantic>=2.0.2,<3.0.0"
- name: Lint
if: matrix.pydantic-version == 'pydantic-v2'
if: matrix.pydantic-version == 'pydantic-v2' && matrix.python-version != '3.8'
run: bash scripts/lint.sh
- run: mkdir coverage
- name: Test
Expand Down
2 changes: 1 addition & 1 deletion sqlmodel/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def set_config_value(
model.model_config[parameter] = value # type: ignore[literal-required]

def get_model_fields(model: InstanceOrType[BaseModel]) -> Dict[str, "FieldInfo"]:
return model.model_fields
return model.model_fields # type: ignore[arg-type]

def get_fields_set(
object: InstanceOrType["SQLModel"],
Expand Down
15 changes: 11 additions & 4 deletions sqlmodel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def Relationship(
class SQLModelMetaclass(ModelMetaclass, DeclarativeMeta):
__sqlmodel_relationships__: Dict[str, RelationshipInfo]
model_config: SQLModelConfig
model_fields: Dict[str, FieldInfo] # type: ignore[assignment]
model_fields: Dict[str, FieldInfo]
__config__: Type[SQLModelConfig]
__fields__: Dict[str, ModelField] # type: ignore[assignment]

Expand Down Expand Up @@ -846,8 +846,9 @@ def model_validate(
strict: Union[bool, None] = None,
from_attributes: Union[bool, None] = None,
context: Union[Dict[str, Any], None] = None,
update: Union[Dict[str, Any], None] = None,
**kwargs: Any,
) -> _TSQLModel:
update = kwargs.get("update", None)
return sqlmodel_validate(
cls=cls,
obj=obj,
Expand All @@ -863,20 +864,25 @@ def model_dump(
mode: Union[Literal["json", "python"], str] = "python",
include: Union[IncEx, None] = None,
exclude: Union[IncEx, None] = None,
context: Union[Dict[str, Any], None] = None,
by_alias: bool = False,
context: Union[Any, None] = None,
by_alias: Union[bool, None] = False,
exclude_unset: bool = False,
exclude_defaults: bool = False,
exclude_none: bool = False,
round_trip: bool = False,
warnings: Union[bool, Literal["none", "warn", "error"]] = True,
serialize_as_any: bool = False,
**kwargs: Any,
) -> Dict[str, Any]:
fallback = kwargs.get("fallback", None)
if PYDANTIC_MINOR_VERSION >= (2, 7):
extra_kwargs: Dict[str, Any] = {
"context": context,
"serialize_as_any": serialize_as_any,
}
if PYDANTIC_MINOR_VERSION >= (2, 11):
extra_kwargs["fallback"] = fallback

else:
extra_kwargs = {}
if IS_PYDANTIC_V2:
Expand All @@ -893,6 +899,7 @@ def model_dump(
**extra_kwargs,
)
else:
assert by_alias is not None
return super().dict(
include=include,
exclude=exclude,
Expand Down