Skip to content

Commit 4695252

Browse files
authored
Fixed typing error in session.get. (#221)
The type '_T' has been defined as the 'Union[Connection, Engine]' type in the 'Session' class.
1 parent 096574a commit 4695252

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

sqlalchemy-stubs/orm/session.pyi

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ from ..sql import Executable
3636
from ..sql.base import Options
3737

3838
_T = TypeVar("_T")
39+
_M = TypeVar("_M")
3940
_TSession = TypeVar("_TSession", bound=Session)
4041
_TSessionNoIoTypingCommon = TypeVar(
4142
"_TSession", bound=_SessionNoIoTypingCommon
@@ -150,7 +151,7 @@ class _SessionProtocol(
150151
def delete(self, instance: Any) -> None: ...
151152
def get(
152153
self,
153-
entity: Type[_T],
154+
entity: Type[_M],
154155
ident: Any,
155156
options: Optional[Sequence[Any]] = ...,
156157
populate_existing: bool = ...,
@@ -159,13 +160,13 @@ class _SessionProtocol(
159160
] = ...,
160161
identity_token: Optional[Any] = ...,
161162
execution_options: Optional[_ExecuteOptions] = ...,
162-
) -> Optional[_T]: ...
163+
) -> Optional[_M]: ...
163164
def merge(
164165
self,
165-
instance: _T,
166+
instance: _M,
166167
load: bool = ...,
167168
options: Optional[Sequence[Any]] = ...,
168-
) -> _T: ...
169+
) -> _M: ...
169170
def flush(self, objects: Optional[Collection[Any]] = ...) -> None: ...
170171
@classmethod
171172
def close_all(cls) -> None: ... # NOTE: Deprecated.
@@ -376,7 +377,7 @@ class _SessionTypingCommon(
376377
def flush(self, objects: Optional[Collection[Any]] = ...) -> None: ...
377378
def get(
378379
self,
379-
entity: Type[_T],
380+
entity: Type[_M],
380381
ident: Any,
381382
options: Optional[Sequence[Any]] = ...,
382383
populate_existing: bool = ...,
@@ -385,7 +386,7 @@ class _SessionTypingCommon(
385386
] = ...,
386387
identity_token: Optional[Any] = ...,
387388
execution_options: Optional[_ExecuteOptions] = ...,
388-
) -> Optional[_T]: ...
389+
) -> Optional[_M]: ...
389390
def bulk_save_objects(
390391
self,
391392
objects: Sequence[Any],
@@ -405,10 +406,10 @@ class _SessionTypingCommon(
405406
) -> None: ...
406407
def merge(
407408
self,
408-
instance: _T,
409+
instance: _M,
409410
load: bool = ...,
410411
options: Optional[Sequence[Any]] = ...,
411-
) -> _T: ...
412+
) -> _M: ...
412413
def query(self, *entities: Any, **kwargs: Any) -> Query[Any]: ...
413414
def refresh(
414415
self,

0 commit comments

Comments
 (0)