fix(types): use Union[Arrow, dt_datetime] for span_range and interval start/end params#1267
Open
juliosuas wants to merge 3 commits intoarrow-py:masterfrom
Open
fix(types): use Union[Arrow, dt_datetime] for span_range and interval start/end params#1267juliosuas wants to merge 3 commits intoarrow-py:masterfrom
juliosuas wants to merge 3 commits intoarrow-py:masterfrom
Conversation
… start/end params Arrow.range() already typed start/end as Union['Arrow', dt_datetime] since both types work via fromdatetime() internally. span_range() and interval() accept the same union but were typed as dt_datetime only, causing mypy/pyright errors when passing Arrow objects directly. Aligns the type signatures of all three class methods for consistency. Fixes arrow-py#1210.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1267 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 2315 2315
Branches 358 358
=========================================
Hits 2315 2315 ☔ View full report in Codecov by Sentry. |
…ime calls fromdatetime() only accepts datetime, not Arrow. span_range and interval now call cls._get_datetime(start/end) to convert Arrow objects to their underlying datetime before passing to fromdatetime — matching the pattern already used in Arrow.range(). This satisfies mypy while preserving the Union[Arrow, dt_datetime] type hint on the public API.
Author
|
😁 |
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.
Problem
Arrow.span_range()andArrow.interval()accept bothArrowanddatetimeobjects for theirstart/endparameters (they pass throughfromdatetime()internally), but their type hints only declaredt_datetime.This means type checkers (mypy, pyright) raise false errors when passing
Arrowobjects directly:Fix
Arrow.range()already uses the correct typeUnion['Arrow', dt_datetime]for itsstart/endparams. This PR applies the same fix tospan_range()andinterval()for consistency.Fixes #1210.