fix(types): use Union[Arrow, dt_datetime] for span_range and interval start/end params#1267
fix(types): use Union[Arrow, dt_datetime] for span_range and interval start/end params#1267juliosuas wants to merge 4 commits into
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.
|
😁 |
|
Small maintainer note: this PR is still mergeable with the full check matrix green. The change is intentionally narrow: it updates the public typing for Happy to adjust the annotation shape if you prefer a different style for this API surface. |
|
Follow-up after bringing this branch up to date with So this looks like a transient package download/network failure rather than a failure from this PR. I tried to rerun the failed job, but GitHub requires repository admin permissions for that action. |
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.