8000 fix issue with _AsyncSessionProtocol by CaselIT · Pull Request #157 · sqlalchemy/sqlalchemy2-stubs · GitHub
[go: up one dir, main page]

Skip to content

fix issue with _AsyncSessionProtocol #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sqlalchemy-stubs/ext/asyncio/session.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ class _AsyncSessionProtocol(
async def close_all(cls) -> None: ... # NOTE: Deprecated.

class _AsyncSessionTypingCommon(
_SessionNoIoTypingCommon, _SessionClassMethodNoIoTypingCommon
_SessionNoIoTypingCommon[Union[AsyncConnection, AsyncEngine]],
_SessionClassMethodNoIoTypingCommon,
):
bind: Any = ...
def begin(self, **kw: Any) -> AsyncSessionTransaction: ...
Expand Down
10 changes: 6 additions & 4 deletions sqlalchemy-stubs/orm/session.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class SessionTransaction:
def __enter__(self: _TSessionTransaction) -> _TSessionTransaction: ...
def __exit__(self, type_: Any, value: Any, traceback: Any) -> None: ...

class _SessionNoIoTypingCommon:
class _SessionNoIoTypingCommon(Generic[_T]):
@property
def dirty(self) -> util.IdentitySet[Any]: ...
@property
Expand Down Expand Up @@ -321,15 +321,17 @@ class _SessionNoIoTypingCommon:
self,
mapper: Optional[Any] = ...,
clause: Optional[ClauseElement] = ...,
bind: Optional[Union[Connection, Engine]] = ...,
bind: Optional[_T] = ...,
_sa_skip_events: Optional[Any] = ...,
_sa_skip_for_implicit_returning: bool = ...,
) -> Union[Connection, Engine]: ...
) -> _T: ...
def is_modified(
self, instance: Any, include_collections: bool = ...
) -> bool: ...

class _SessionTypingCommon(_SessionNoIoTypingCommon):
class _SessionTypingCommon(
_SessionNoIoTypingCommon[Union[Connection, Engine]]
):
bind: Optional[Union[Connection, Engine]]
autocommit: bool
def begin(
Expand Down
7 changes: 7 additions & 0 deletions test/files/async_stuff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.ext.asyncio import create_async_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import Session

engine = create_async_engine(...)
async_session = sessionmaker(engine, class_=AsyncSession)
0