Skip to content

Commit d04a1ef

Browse files
authored
Add missing stubs for ClauseElement.__and__ and ClauseElement.__or__ (#215)
* Add missing stubs for `ClauseElement.__and__` and `ClauseElement.__or__` Fixes #111. * Run tox against the `rel_1_4` branch, not `main` * Add `await`s to appease newer mypy mypy 0.950 added a feature to detect unused coroutines and awaitables.
1 parent 243b03b commit d04a1ef

File tree

3 files changed

+41
-37
lines changed

3 files changed

+41
-37
lines changed

sqlalchemy-stubs/sql/elements.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ class ClauseElement(
113113
dialect: Optional[Dialect] = ...,
114114
**kw: Any,
115115
) -> SQLCompiler: ...
116+
def __and__(self, other: Any) -> BooleanClauseList: ...
117+
def __or__(self, other: Any) -> BooleanClauseList: ...
116118
def __invert__(self) -> Any: ...
117119
def __bool__(self) -> bool: ...
118120
def __nonzero__(self) -> bool: ...

test/files/create_proxy_methods.py

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -54,43 +54,45 @@ async def go_async_conn() -> None:
5454
async_session.no_autoflush
5555
async_session.info
5656

57+
5758
# async scoped session
58-
async_scoped_session.object_session(object())
59-
async_scoped_session.identity_key()
60-
async_scoped_session.close_all()
61-
async_ss = async_scoped_session(AsyncSession, lambda: 42)
62-
"foo" in async_ss
63-
list(async_ss)
64-
async_ss.add(object())
65-
async_ss.add_all([])
66-
async_ss.begin()
67-
async_ss.begin_nested()
68-
async_ss.close()
69-
async_ss.commit()
70-
async_ss.connection()
71-
async_ss.delete(object())
72-
async_ss.execute(text("select 1"))
73-
async_ss.expire(object())
74-
async_ss.expire_all()
75-
async_ss.expunge(object())
76-
async_ss.expunge_all()
77-
async_ss.flush()
78-
async_ss.get(object, 1)
79-
async_ss.get_bind()
80-
async_ss.is_modified(object())
81-
async_ss.merge(object())
82-
async_ss.refresh(object())
83-
async_ss.rollback()
84-
async_ss.scalar(text("select 1"))
85-
async_ss.bind
86-
async_ss.dirty
87-
async_ss.deleted
88-
async_ss.new
89-
async_ss.identity_map
90-
async_ss.is_active
91-
async_ss.autoflush
92-
async_ss.no_autoflush
93-
async_ss.info
59+
async def test_async_scoped_session() -> None:
60+
async_scoped_session.object_session(object())
61+
async_scoped_session.identity_key()
62+
await async_scoped_session.close_all()
63+
async_ss = async_scoped_session(AsyncSession, lambda: 42)
64+
"foo" in async_ss
65+
list(async_ss)
66+
async_ss.add(object())
67+
async_ss.add_all([])
68+
async_ss.begin()
69+
async_ss.begin_nested()
70+
await async_ss.close()
71+
await async_ss.commit()
72+
await async_ss.connection()
73+
await async_ss.delete(object())
74+
await async_ss.execute(text("select 1"))
75+
async_ss.expire(object())
76+
async_ss.expire_all()
77+
async_ss.expunge(object())
78+
async_ss.expunge_all()
79+
await async_ss.flush()
80+
await async_ss.get(object, 1)
81+
async_ss.get_bind()
82+
async_ss.is_modified(object())
83+
await async_ss.merge(object())
84+
await async_ss.refresh(object())
85+
await async_ss.rollback()
86+
await async_ss.scalar(text("select 1"))
87+
async_ss.bind
88+
async_ss.dirty
89+
async_ss.deleted
90+
async_ss.new
91+
async_ss.identity_map
92+
async_ss.is_active
93+
async_ss.autoflush
94+
async_ss.no_autoflush
95+
async_ss.info
9496

9597
# scoped session
9698
scoped_session.object_session(object())

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
; envlist = py
44

55
SQLA_REPO = {env:SQLA_REPO:https://github.com/sqlalchemy/sqlalchemy.git}
6-
SQLA_REF = {env:SQLA_REF:main}
6+
SQLA_REF = {env:SQLA_REF:rel_1_4}
77

88
[testenv]
99

0 commit comments

Comments
 (0)