Convert Python native values (int/float/bool) to Literal nodes
(self, value)
| 42 | # Utility: Convert Python values to Literal |
| 43 | # ------------------------------ |
| 44 | def _to_expr(self, value) -> "Expr": |
| 45 | """Convert Python native values (int/float/bool) to Literal nodes""" |
| 46 | if isinstance(value, Expr): |
| 47 | return value |
| 48 | if isinstance(value, int): |
| 49 | return Literal(value, int32) # Simplification: default int to int32 |
| 50 | if isinstance(value, float): |
| 51 | return Literal(value, float32) # Simplification: default float to float32 |
| 52 | if isinstance(value, bool): |
| 53 | return Literal(value, bool_) |
| 54 | if isinstance(value, str): |
| 55 | return Literal(value, str_) |
| 56 | raise TypeError(f"Unsupported operand type: {type(value)}") |
| 57 | |
| 58 | # ------------------------------ |
| 59 | # Binary operator overloading (arithmetic) |
no test coverage detected