anxkhn opened a new pull request, #3634:
URL: https://github.com/apache/iceberg-python/pull/3634
# Rationale for this change
`LongAboveMax.to()` and `LongBelowMin.to()` fall back to
`raise TypeError("Cannot change the type of ...")` when asked to convert to
an
unsupported type, but the class name in each message was left as
`IntAboveMax` /
`IntBelowMin`, a copy-paste leftover from the `IntAboveMax` / `IntBelowMin`
singletons defined just above. So when a long overflow sentinel is converted
to
an unsupported type, the diagnostic misidentifies it as an int literal,
which is
misleading when debugging.
For comparison, the neighbouring sentinels already name themselves correctly:
`FloatAboveMax` / `FloatBelowMin`, `IntAboveMax` / `IntBelowMin`. Only the
two
`Long*` messages are wrong.
This is the same class of copy-paste-from-the-`Int`-handler slip that
`DecimalLiteral.to(LongType)` had in #3469 (fixed by #3470, which corrected
the
returned sentinel *object*); this PR fixes the remaining instance in the
diagnostic *messages* on the `Long*` singletons themselves.
Change: point each message at its own class:
- `pyiceberg/expressions/literals.py` `LongAboveMax.to`: `IntAboveMax` ->
`LongAboveMax`
- `pyiceberg/expressions/literals.py` `LongBelowMin.to`: `IntBelowMin` ->
`LongBelowMin`
## Are these changes tested?
Yes. Added `test_above_max_long` and `test_below_min_long` in
`tests/expressions/test_literals.py`, mirroring the existing
`test_above_max_int`
/ `test_below_min_int` (singleton identity, `str`/`repr`, `value`, the
successful
`.to(LongType())` round-trip) and additionally asserting that
`.to(IntegerType())`
raises `TypeError` whose message now names the `Long*` class.
Verified red -> green: reverting only the source change makes both new tests
fail
with `'Cannot change the type of LongBelowMin' in 'Cannot change the type of
IntBelowMin'`; with the fix, both pass.
`tests/expressions/test_literals.py`: 172
passed. `tests/expressions/`: 566 passed, no regressions. `make lint` (ruff,
ruff-format, mypy, pydocstyle, codespell, license/header) passes on the
changed
files.
## Are there any user-facing changes?
No API or behavior change. Only the text of an already-raised `TypeError` is
corrected (the exception type and the conditions under which it is raised are
unchanged). No changelog entry needed.
--
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]