rdblue commented on code in PR #6139:
URL: https://github.com/apache/iceberg/pull/6139#discussion_r1024486151
##########
python/pyiceberg/expressions/visitors.py:
##########
@@ -60,125 +60,127 @@
PrimitiveType,
)
+R = TypeVar("R")
-class BooleanExpressionVisitor(Generic[T], ABC):
+
+class BooleanExpressionVisitor(Generic[R], ABC):
@abstractmethod
- def visit_true(self) -> T:
+ def visit_true(self) -> R:
"""Visit method for an AlwaysTrue boolean expression
Note: This visit method has no arguments since AlwaysTrue instances
have no context.
"""
@abstractmethod
- def visit_false(self) -> T:
+ def visit_false(self) -> R:
"""Visit method for an AlwaysFalse boolean expression
Note: This visit method has no arguments since AlwaysFalse instances
have no context.
"""
@abstractmethod
- def visit_not(self, child_result: T) -> T:
+ def visit_not(self, child_result: R) -> R:
"""Visit method for a Not boolean expression
Args:
child_result (T): The result of visiting the child of the Not
boolean expression
"""
@abstractmethod
- def visit_and(self, left_result: T, right_result: T) -> T:
+ def visit_and(self, left_result: R, right_result: R) -> R:
"""Visit method for an And boolean expression
Args:
- left_result (T): The result of visiting the left side of the
expression
- right_result (T): The result of visiting the right side of the
expression
+ left_result (R): The result of visiting the left side of the
expression
+ right_result (R): The result of visiting the right side of the
expression
"""
@abstractmethod
- def visit_or(self, left_result: T, right_result: T) -> T:
+ def visit_or(self, left_result: R, right_result: R) -> R:
"""Visit method for an Or boolean expression
Args:
- left_result (T): The result of visiting the left side of the
expression
- right_result (T): The result of visiting the right side of the
expression
+ left_result (R): The result of visiting the left side of the
expression
+ right_result (R): The result of visiting the right side of the
expression
"""
@abstractmethod
- def visit_unbound_predicate(self, predicate) -> T:
+ def visit_unbound_predicate(self, predicate: UnboundPredicate) -> R:
Review Comment:
Seems like `UnaryPredicate` could just extend `UnboundPredicate[Any]` to
solve this as well. I think we will eventually need to do that, if we want to
add a type to `Reference`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]