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)}")
-
-
[email protected](bool)
-def _(value: bool) -> Literal[bool]:
- return BooleanLiteral(value)
-
-
[email protected](int)
-def _(value: int) -> Literal[int]:
- return LongLiteral(value)
-
-
[email protected](float)
-def _(value: float) -> Literal[float]:
- # expression binding can convert to FloatLiteral if needed
- return DoubleLiteral(value)
-
-
[email protected](str)
-def _(value: str) -> Literal[str]:
- return StringLiteral(value)
-
-
[email protected](UUID)
-def _(value: UUID) -> Literal[UUID]:
- return UUIDLiteral(value)
-
-
[email protected](bytes)
-def _(value: bytes) -> Literal[bytes]:
- # expression binding can convert to FixedLiteral if needed
- return BinaryLiteral(value)
-
-
[email protected](bytearray)
-def _(value: bytearray) -> Literal[bytes]:
- return BinaryLiteral(bytes(value))
-
-
[email protected](Decimal)
-def _(value: Decimal) -> Literal[Decimal]:
- return DecimalLiteral(value)
-
-
[email protected](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: [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]