rdblue commented on code in PR #6139:
URL: https://github.com/apache/iceberg/pull/6139#discussion_r1024222276
##########
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:
"""Visit method for an unbound predicate in an expression tree
Args:
predicate (UnboundPredicate): An instance of an UnboundPredicate
"""
@abstractmethod
- def visit_bound_predicate(self, predicate) -> T:
+ def visit_bound_predicate(self, predicate: BoundPredicate[T]) -> R:
Review Comment:
I think that if we are going to share a type param for values wrapped by a
literal, then it should be something other than `T` because `T` is used as a
generic type in a lot of places. `L` would be fine with me as long as we're
making all these changes.
--
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]