MINOR: [Python] Mention interval in the is_temporal docstring - #51016
Open
Nishuuzz wants to merge 1 commit into
Open
MINOR: [Python] Mention interval in the is_temporal docstring#51016Nishuuzz wants to merge 1 commit into
Nishuuzz wants to merge 1 commit into
Conversation
`pyarrow.types.is_temporal()` returns True for interval types, since `_TEMPORAL_TYPES` is built from `_INTERVAL_TYPES` along with the date, time, timestamp and duration ids, and `test_is_temporal_date_time_timestamp` asserts that it does. The generated docstring only listed "date, time, timestamp or duration", so the documented contract was narrower than the behaviour. Add interval to the list. No behaviour change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pyarrow.types.is_temporal()returns True for interval types, but its docstring doesn't say so:That's the documented contract being narrower than the behaviour, and since these docstrings are generated from the
@doc(is_null, datatype=...)decorator they're what ends up on the API docs page.Including interval is deliberate rather than accidental —
_TEMPORAL_TYPESis built asand
test_is_temporal_date_time_timestampalready assertstypes.is_temporal(pa.month_day_nano_interval()). So this is a docs fix, not a behaviour question; I've only changed thedatatypestring.After the change the rendered line is
which is exactly the set that returns True — I checked each one (date32, time32, timestamp, duration, interval all True; int32 False) by applying the same edit to an installed pyarrow and reading the generated docstring back.
I found this while comparing every predicate set in
types.pyagainst the correspondingarrow::is_*()incpp/src/arrow/type_traits.h, the same way GH-50847 turned up. Worth noting the twois_temporaldefinitions genuinely differ — the C++ one covers only date/time/timestamp, while Python also counts duration and interval — but that's a semantic question rather than something to change quietly in a MINOR PR, so I've left it alone and only made the Python docstring match the Python behaviour.