]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Add type annotations to CollectionAggregate.operate()
authorDenis Laxalde <denis@laxalde.org>
Sat, 1 Mar 2025 15:25:01 +0000 (16:25 +0100)
committerDenis Laxalde <denis@laxalde.org>
Sat, 1 Mar 2025 16:45:09 +0000 (17:45 +0100)
This will help when adding type annotations to ARRAY next.

lib/sqlalchemy/sql/elements.py

index 825123a977eee99242b55165de60e971fbcbb96f..e33971e8fac26a124e6177cb1378185f236cd2b7 100644 (file)
@@ -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(