(value: Value)
| 463 | |
| 464 | |
| 465 | def _extract_python_literal(value: Value) -> object: |
| 466 | if isinstance(value, Integer): |
| 467 | if is_none_rprimitive(value.type): |
| 468 | return None |
| 469 | val = value.numeric_value() |
| 470 | if is_bool_rprimitive(value.type): |
| 471 | return bool(val) |
| 472 | return val |
| 473 | elif isinstance(value, Float): |
| 474 | return value.value |
| 475 | elif isinstance(value, LoadLiteral): |
| 476 | return value.value |
| 477 | elif isinstance(value, Box): |
| 478 | return _extract_python_literal(value.src) |
| 479 | elif isinstance(value, TupleSet): |
| 480 | items = tuple(_extract_python_literal(item) for item in value.items) |
| 481 | if any(itm is _NOT_REPRESENTABLE for itm in items): |
| 482 | return _NOT_REPRESENTABLE |
| 483 | return items |
| 484 | return _NOT_REPRESENTABLE |
no test coverage detected
searching dependent graphs…