Skip to content

Commit 66c1d93

Browse files
author
John Lyu
committed
lint
1 parent 015601c commit 66c1d93

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sqlmodel/_compat.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,16 @@ def _is_union_type(t: Any) -> bool:
6666
finish_init: ContextVar[bool] = ContextVar("finish_init", default=True)
6767

6868

69-
def set_polymorphic_default_value(self_instance, values):
69+
def set_polymorphic_default_value(
70+
self_instance: _TSQLModel,
71+
values: Dict[str, Any],
72+
) -> bool:
7073
"""By defalut, when init a model, pydantic will set the polymorphic_on
7174
value to field default value. But when inherit a model, the polymorphic_on
7275
should be set to polymorphic_identity value by default."""
7376
cls = type(self_instance)
7477
mapper = inspect(cls)
78+
ret = False
7579
if isinstance(mapper, Mapper):
7680
polymorphic_on = mapper.polymorphic_on
7781
if polymorphic_on is not None:
@@ -87,6 +91,8 @@ def set_polymorphic_default_value(self_instance, values):
8791
polymorphic_property.key,
8892
mapper.polymorphic_identity,
8993
)
94+
ret = True
95+
return ret
9096

9197

9298
@contextmanager

0 commit comments

Comments
 (0)