From: Denis Laxalde Date: Sat, 1 Mar 2025 15:25:01 +0000 (+0100) Subject: Add type annotations to CollectionAggregate.operate() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b1f80663a8554cd6a0ba87a18e0767a118b621d;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Add type annotations to CollectionAggregate.operate() This will help when adding type annotations to ARRAY next. --- 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(