Skip to content

is_between: name the offending type of the end argument, not the start argument#1320

Open
HrachShah wants to merge 1 commit into
arrow-py:masterfrom
HrachShah:fix/is-between-error-message-end-type
Open

is_between: name the offending type of the end argument, not the start argument#1320
HrachShah wants to merge 1 commit into
arrow-py:masterfrom
HrachShah:fix/is-between-error-message-end-type

Conversation

@HrachShah

Copy link
Copy Markdown

What

Arrow.is_between raises a TypeError when start or end is not an Arrow instance. The check for end formats the error message using type(start) instead of type(end), so the message misleads the user when only end is wrong.

Why

The first TypeError for start correctly names the offending type (the user passed something that wasn't an Arrow). The second TypeError for end was a copy-paste that re-uses type(start) — so if start is a perfectly valid Arrow and the user passes a datetime as end, the error says Cannot parse end date argument type of <class 'arrow.arrow.Arrow'>., which is confusing.

Fix

Use type(end) in the second error message so it accurately describes the offending argument.

Tests

Added test_is_between_error_message_mentions_end_type to tests/test_arrow.py::TestArrowIsBetween that passes a datetime for end and asserts the error message mentions end and datetime and does not mention Arrow. All 226 tests in tests/test_arrow.py pass.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

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

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

☔ View full report in Codecov by Harness.
📢 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.

1 participant