diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-01-19 15:34:46 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-01-20 09:13:58 -0500 |
commit | d1eeef5e67fa4632f88a894f0c5cf4445f04ba2b (patch) | |
tree | 30f2ad05dbf45bb2aa5dc33502a24cbdc5281097 /test/ext/mypy/plain_files/sql_operations.py | |
parent | e82a5f19e1606500ad4bf6a456c2558d74df24bf (diff) | |
download | sqlalchemy-d1eeef5e67fa4632f88a894f0c5cf4445f04ba2b.tar.gz |
typing updates
The :meth:`_sql.ColumnOperators.in_` and
:meth:`_sql.ColumnOperators.not_in_` are typed to include
``Iterable[Any]`` rather than ``Sequence[Any]`` for more flexibility in
argument type.
The :func:`_sql.or_` and :func:`_sql.and_` from a typing perspective
require the first argument to be present, however these functions still
accept zero arguments which will emit a deprecation warning at runtime.
Typing is also added to support sending the fixed literal ``False`` for
:func:`_sql.or_` and ``True`` for :func:`_sql.and_` as the first argument
only, however the documentation now indicates sending the
:func:`_sql.false` and :func:`_sql.true` constructs in these cases as a
more explicit approach.
Fixed typing issue where iterating over a :class:`_orm.Query` object
was not correctly typed.
Fixes: #9122
Fixes: #9123
Fixes: #9125
Change-Id: I500e3e1b826717b3dd49afa1e682c3c8279c9226
Diffstat (limited to 'test/ext/mypy/plain_files/sql_operations.py')
-rw-r--r-- | test/ext/mypy/plain_files/sql_operations.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/ext/mypy/plain_files/sql_operations.py b/test/ext/mypy/plain_files/sql_operations.py index 0ed0df661..33db5f2cc 100644 --- a/test/ext/mypy/plain_files/sql_operations.py +++ b/test/ext/mypy/plain_files/sql_operations.py @@ -1,11 +1,15 @@ import typing +from sqlalchemy import and_ from sqlalchemy import Boolean from sqlalchemy import column +from sqlalchemy import false from sqlalchemy import func from sqlalchemy import Integer +from sqlalchemy import or_ from sqlalchemy import select from sqlalchemy import String +from sqlalchemy import true # builtin.pyi stubs define object.__eq__() as returning bool, which @@ -21,6 +25,28 @@ c2 = column("a", Integer) expr2 = c2.in_([1, 2, 3]) +expr2_set = c2.in_({1, 2, 3}) + +expr2_gen = c2.in_((x for x in (1, 2, 3))) + +nexpr2 = c2.not_in([1, 2, 3]) + +nexpr2_set = c2.not_in({1, 2, 3}) + +nexpr2_gen = c2.not_in((x for x in (1, 2, 3))) + +short_cir1 = and_(True, c2 == 5) +short_cir2 = or_(False, c2 == 5) + +short_cir3 = and_(true(), c2 == 5) +short_cir4 = or_(false(), c2 == 5) + +# EXPECTED_MYPY: Missing positional argument "initial_clause" in call to "and_" +no_empty_1 = and_() + +# EXPECTED_MYPY: Missing positional argument "initial_clause" in call to "or_" +no_empty_2 = or_() + expr3 = c2 / 5 expr4 = -c2 |