sqlmodel icon indicating copy to clipboard operation
sqlmodel copied to clipboard

✨ Add UpdateBase overload for exec method in AsyncSession and Session

Open seriaati opened this issue 9 months ago • 1 comments

To address #909

seriaati avatar Apr 10 '25 00:04 seriaati

On #1349 you asked for feedbacks on your PR: I tested it and it fixed my typing errors!

Previously I had this mypy output:

src/ddd/infrastructure/manager.py:263: error: No overload variant of "exec" of "Session" matches argument type "Update"  [call-overload]
src/ddd/infrastructure/manager.py:263: note: Possible overload variants:
src/ddd/infrastructure/manager.py:263: note:     def [_TSelectParam: Any] exec(self, statement: Select[_TSelectParam], *, params: Mapping[str, Any] | Sequence[Mapping[str, Any]] | None = ..., execution_options: Mapping[str, Any] = ..., bind_arguments: dict[str, Any] | None = ..., _parent_execute_state: Any | None = ..., _add_event: Any | None = ...) -> TupleResult[_TSelectParam]
src/ddd/infrastructure/manager.py:263: note:     def [_TSelectParam: Any] exec(self, statement: SelectOfScalar[_TSelectParam], *, params: Mapping[str, Any] | Sequence[Mapping[str, Any]] | None = ..., execution_options: Mapping[str, Any] = ..., bind_arguments: dict[str, Any] | None = ..., _parent_execute_state: Any | None = ..., _add_event: Any | None = ...) -> ScalarResult[_TSelectParam]

After applying your patch, the type error is solved. Thanks a lot, hope your patch will be merged soon so everyone can benefit from this typing fix in sqlmodel :star2:

superboum avatar Jun 03 '25 10:06 superboum

Hope this gets merged soon! Good job @seriaati

pizzashuai avatar Jun 21 '25 01:06 pizzashuai