Skip to content

Fix type hints for interval and span_range to accept Arrow objects#1255

Open
rstar327 wants to merge 2 commits intoarrow-py:masterfrom
rstar327:fix-interval-type-hints
Open

Fix type hints for interval and span_range to accept Arrow objects#1255
rstar327 wants to merge 2 commits intoarrow-py:masterfrom
rstar327:fix-interval-type-hints

Conversation

@rstar327
Copy link

@rstar327 rstar327 commented Feb 26, 2026

Pull Request Checklist

  • 🧪 Added tests for changed code.
  • 🛠️ All tests pass when run locally (run tox or make test to find out!).
  • 🧹 All linting checks pass when run locally (run tox -e lint or make lint to find out!).
  • 📚 Updated documentation for changed code.
  • ⏩ Code is up-to-date with the master branch.

Description of Changes

Arrow.interval and Arrow.span_range accept Arrow objects for start and end parameters, but the type hints only specified datetime.datetime. This causes false type errors in type checkers like mypy/pyright.

Updated type hints from dt_datetime to Union["Arrow", dt_datetime] for both methods, matching the existing pattern used in Arrow.range.

Added test_arrow_objects_as_start_end to verify Arrow objects work correctly with interval. All 1905 tests pass.

Closes: #1210

@codecov
Copy link

codecov bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b423717) to head (84d04f6).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #1255   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines         2315      2315           
  Branches       358       358           
=========================================
  Hits          2315      2315           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type hints for Arrow.interval should show Arrow as possible type for start and end arguments

1 participant