From 5b1f80663a8554cd6a0ba87a18e0767a118b621d Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Sat, 1 Mar 2025 16:25:01 +0100 Subject: [PATCH] Add type annotations to CollectionAggregate.operate() This will help when adding type annotations to ARRAY next. --- lib/sqlalchemy/sql/elements.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index 825123a977..e33971e8fa 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -3791,7 +3791,9 @@ class CollectionAggregate(UnaryExpression[_T]): # operate and reverse_operate are hardwired to # dispatch onto the type comparator directly, so that we can # ensure "reversed" behavior. - def operate(self, op, *other, **kwargs): + def operate( + self, op: OperatorType, *other: Any, **kwargs: Any + ) -> ColumnElement[_T]: if not operators.is_comparison(op): raise exc.ArgumentError( "Only comparison operators may be used with ANY/ALL" @@ -3799,7 +3801,9 @@ class CollectionAggregate(UnaryExpression[_T]): kwargs["reverse"] = True return self.comparator.operate(operators.mirror(op), *other, **kwargs) - def reverse_operate(self, op, other, **kwargs): + def reverse_operate( + self, op: OperatorType, other: Any, **kwargs: Any + ) -> ColumnElement[_T]: # comparison operators should never call reverse_operate assert not operators.is_comparison(op) raise exc.ArgumentError( -- 2.47.3