Fokko commented on code in PR #6141:
URL: https://github.com/apache/iceberg/pull/6141#discussion_r1019523027


##########
python/pyiceberg/expressions/literals.py:
##########
@@ -58,25 +60,25 @@
     timestamp_to_micros,
     timestamptz_to_micros,
 )
-from pyiceberg.utils.singleton import Singleton
 
 T = TypeVar("T")
 
 
 class Literal(Generic[T], ABC):
     """Literal which has a value and can be converted between types"""
 
-    def __init__(self, value: T, value_type: type):
+    def __init__(self, value: T, value_type: Type):
         if value is None or not isinstance(value, value_type):
             raise TypeError(f"Invalid literal value: {value} (not a 
{value_type})")
         self._value = value
 
     @property
     def value(self) -> T:
-        return self._value  # type: ignore
+        return self._value
 
+    @singledispatchmethod
     @abstractmethod
-    def to(self, type_var) -> Literal:
+    def to(self, type_var: IcebergType) -> Literal:

Review Comment:
   I think this PR improves the typing since we return a `Literal` in all the 
cases (or raise an exception).
   
   To get this fully working, I think we need to add type information to the 
IcebergType, and then we can do the following:
   ```suggestion
       def to(self, type_var: IcebergType[T]) -> Literal[T]:
   ```



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to