diff options
author | Dzmitar <17720985+dzmitar@users.noreply.github.com> | 2023-01-12 10:47:24 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-01-13 12:05:15 -0500 |
commit | 73389e94aefd4604c9f1b1ba744e0e74c99d8371 (patch) | |
tree | 72455acb4378593726945d71716f91ea1740e8ea /lib/sqlalchemy/sql/base.py | |
parent | c5a6c3e70e5d75497cc5e7d2929e496251294523 (diff) | |
download | sqlalchemy-73389e94aefd4604c9f1b1ba744e0e74c99d8371.tar.gz |
Type annotations for sqlalchemy.sql.selectable
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Closes: #9028
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9028
Pull-request-sha: e2f8ddeac0b08feaad917285e988acf1e9465a26
Change-Id: I5caad31bfeeed2d224657a55f067ba1d86b8733f
Diffstat (limited to 'lib/sqlalchemy/sql/base.py')
-rw-r--r-- | lib/sqlalchemy/sql/base.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index 25e214bd3..96ebc7824 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -66,6 +66,7 @@ if TYPE_CHECKING: from . import type_api from ._orm_types import DMLStrategyArgument from ._orm_types import SynchronizeSessionArgument + from ._typing import _CLE from .elements import BindParameter from .elements import ClauseList from .elements import ColumnClause # noqa @@ -282,7 +283,9 @@ def _clone(element, **kw): return element._clone(**kw) -def _expand_cloned(elements): +def _expand_cloned( + elements: Iterable[_CLE], +) -> Iterable[_CLE]: """expand the given set of ClauseElements to be the set of all 'cloned' predecessors. @@ -291,7 +294,7 @@ def _expand_cloned(elements): return itertools.chain(*[x._cloned_set for x in elements]) -def _cloned_intersection(a, b): +def _cloned_intersection(a: Iterable[_CLE], b: Iterable[_CLE]) -> Set[_CLE]: """return the intersection of sets a and b, counting any overlap between 'cloned' predecessors. @@ -302,7 +305,7 @@ def _cloned_intersection(a, b): return {elem for elem in a if all_overlap.intersection(elem._cloned_set)} -def _cloned_difference(a, b): +def _cloned_difference(a: Iterable[_CLE], b: Iterable[_CLE]) -> Set[_CLE]: all_overlap = set(_expand_cloned(a)).intersection(_expand_cloned(b)) return { elem for elem in a if not all_overlap.intersection(elem._cloned_set) |