rdblue commented on code in PR #6139: URL: https://github.com/apache/iceberg/pull/6139#discussion_r1027143847
########## python/pyiceberg/expressions/literals.py: ########## @@ -123,54 +115,22 @@ def literal(value: Any) -> Literal: >>> literal(123) LongLiteral(123) """ - raise TypeError(f"Invalid literal value: {repr(value)}") - - -@literal.register(bool) -def _(value: bool) -> Literal[bool]: - return BooleanLiteral(value) - - -@literal.register(int) -def _(value: int) -> Literal[int]: - return LongLiteral(value) - - -@literal.register(float) -def _(value: float) -> Literal[float]: - # expression binding can convert to FloatLiteral if needed - return DoubleLiteral(value) - - -@literal.register(str) -def _(value: str) -> Literal[str]: - return StringLiteral(value) - - -@literal.register(UUID) -def _(value: UUID) -> Literal[UUID]: - return UUIDLiteral(value) - - -@literal.register(bytes) -def _(value: bytes) -> Literal[bytes]: - # expression binding can convert to FixedLiteral if needed - return BinaryLiteral(value) - - -@literal.register(bytearray) -def _(value: bytearray) -> Literal[bytes]: - return BinaryLiteral(bytes(value)) - - -@literal.register(Decimal) -def _(value: Decimal) -> Literal[Decimal]: - return DecimalLiteral(value) - - -@literal.register(date) -def _(value: date) -> Literal[int]: - return DateLiteral(date_to_days(value)) + if isinstance(value, float): + return DoubleLiteral(value) + elif isinstance(value, bool): + return BooleanLiteral(value) # type: ignore Review Comment: This has to be a mypy bug, right? Why would it expect `Literal[int]` since the `bool` is the most specific inference for `L`? How strange. -- 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