Skip to content

Commit

Permalink
Fixed typing error in session.get. (#221)
Browse files Browse the repository at this point in the history
The type '_T' has been defined as the 'Union[Connection, Engine]' type in the 'Session' class.
  • Loading branch information
amisadmin authored Aug 9, 2022
1 parent 096574a commit 4695252
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions sqlalchemy-stubs/orm/session.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ from ..sql import Executable
from ..sql.base import Options

_T = TypeVar("_T")
_M = TypeVar("_M")
_TSession = TypeVar("_TSession", bound=Session)
_TSessionNoIoTypingCommon = TypeVar(
"_TSession", bound=_SessionNoIoTypingCommon
Expand Down Expand Up @@ -150,7 +151,7 @@ class _SessionProtocol(
def delete(self, instance: Any) -> None: ...
def get(
self,
entity: Type[_T],
entity: Type[_M],
ident: Any,
options: Optional[Sequence[Any]] = ...,
populate_existing: bool = ...,
Expand All @@ -159,13 +160,13 @@ class _SessionProtocol(
] = ...,
identity_token: Optional[Any] = ...,
execution_options: Optional[_ExecuteOptions] = ...,
) -> Optional[_T]: ...
) -> Optional[_M]: ...
def merge(
self,
instance: _T,
instance: _M,
load: bool = ...,
options: Optional[Sequence[Any]] = ...,
) -> _T: ...
) -> _M: ...
def flush(self, objects: Optional[Collection[Any]] = ...) -> None: ...
@classmethod
def close_all(cls) -> None: ... # NOTE: Deprecated.
Expand Down Expand Up @@ -376,7 +377,7 @@ class _SessionTypingCommon(
def flush(self, objects: Optional[Collection[Any]] = ...) -> None: ...
def get(
self,
entity: Type[_T],
entity: Type[_M],
ident: Any,
options: Optional[Sequence[Any]] = ...,
populate_existing: bool = ...,
Expand All @@ -385,7 +386,7 @@ class _SessionTypingCommon(
] = ...,
identity_token: Optional[Any] = ...,
execution_options: Optional[_ExecuteOptions] = ...,
) -> Optional[_T]: ...
) -> Optional[_M]: ...
def bulk_save_objects(
self,
objects: Sequence[Any],
Expand All @@ -405,10 +406,10 @@ class _SessionTypingCommon(
) -> None: ...
def merge(
self,
instance: _T,
instance: _M,
load: bool = ...,
options: Optional[Sequence[Any]] = ...,
) -> _T: ...
) -> _M: ...
def query(self, *entities: Any, **kwargs: Any) -> Query[Any]: ...
def refresh(
self,
Expand Down

0 comments on commit 4695252

Please sign in to comment.