Skip to content

REF: IntervalArray _validate_setitem_value delegates to _validate_scalar#65174

Merged
mroeschke merged 1 commit intopandas-dev:mainfrom
jbrockmendel:ref-simpler-interval
Apr 16, 2026
Merged

REF: IntervalArray _validate_setitem_value delegates to _validate_scalar#65174
mroeschke merged 1 commit intopandas-dev:mainfrom
jbrockmendel:ref-simpler-interval

Conversation

@jbrockmendel
Copy link
Copy Markdown
Member

Summary

  • Consolidate duplicated validation logic between _validate_scalar and _validate_setitem_value to match the pattern used by DatetimeLikeArrayMixin and Categorical
  • _validate_scalar now includes subdtype compatibility checks (resolving the TODO at the old line 1172), so both methods share a single code path for scalar validation
  • _validate_setitem_value delegates to _validate_scalar for scalars and _validate_listlike for list-like values
  • fillna calls _validate_setitem_value instead of _validate_scalar, matching the standard pattern in NDArrayBackedExtensionArray
  • __setitem__ reordered to match the standard check_array_indexer then _validate_setitem_value pattern

Test plan

  • pandas/tests/arrays/interval/ (210 passed)
  • pandas/tests/indexes/interval/ (1657 passed)
  • pandas/tests/extension/test_interval.py (525 passed)
  • mypy clean on pandas/core/arrays/interval.py
  • All pre-commit hooks pass

🤖 Generated with Claude Code

Consolidate duplicated validation logic between _validate_scalar and
_validate_setitem_value to match the pattern used by DatetimeLikeArrayMixin
and Categorical.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jbrockmendel jbrockmendel added the Refactor Internal refactoring of code label Apr 11, 2026
@jbrockmendel jbrockmendel marked this pull request as ready for review April 15, 2026 17:48
@mroeschke mroeschke added this to the 3.1 milestone Apr 16, 2026
@mroeschke mroeschke merged commit 17521ad into pandas-dev:main Apr 16, 2026
51 checks passed
@mroeschke mroeschke added the Interval Interval data type label Apr 16, 2026
@mroeschke
Copy link
Copy Markdown
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the ref-simpler-interval branch April 16, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Interval Interval data type Refactor Internal refactoring of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants