Skip to content

REF: IntervalArray _validate_setitem_value delegates to _validate_scalar#65174

Draft
jbrockmendel wants to merge 1 commit intopandas-dev:mainfrom
jbrockmendel:ref-simpler-interval
Draft

REF: IntervalArray _validate_setitem_value delegates to _validate_scalar#65174
jbrockmendel wants to merge 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Internal refactoring of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant