Skip to content

fix/iterable list index protocol - #2326

Merged
Byron merged 2 commits into
mainfrom
fix/iterable-list-index-protocol
Oct 29, 2026
Merged

Byron merged 2 commits into
mainfrom
fix/iterable-list-index-protocol

Conversation

@Byron

@Byron Byron commented Oct 29, 2026

Copy link
Copy Markdown
Member

Supersede #2322

Copilot AI balanced review requested due to automatic review settings October 29, 2026 16:52
gavenren and others added 2 commits October 29, 2026 17:57
`IterableList.__getitem__` advertises `SupportsIndex`, but routes every non-`int` index through named lookup. Valid objects implementing `__index__` therefore raise a string-concatenation `TypeError` instead of selecting an element.

Delegate non-string, non-slice indices to the built-in list implementation, which already handles the index protocol and bounds checks. Keep named lookup and explicit slice rejection unchanged.

Six protocol/bounds regressions fail before this fix; a lookup/slice control passes. Utility and typing modules pass with both CLI and Gix backends (128 passed, 39 skipped each). Applicable pre-commit checks pass.

Assisted-by: OpenAI Codex (model: unknown, autonomous)
@Byron
Byron force-pushed the fix/iterable-list-index-protocol branch from 37a1f4f to 451a526 Compare October 29, 2026 16:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the IterableList indexing update.

No open issues 🎉

What changed in this PR

This PR aligns IterableList indexing with its declared SupportsIndex contract, addressing the issue described in #2322 while preserving existing lookup behavior.

Changes:

  • Delegate non-string, non-slice indexing to the built-in list implementation, enabling __index__ support.
  • Add regression tests for protocol-based indices, bounds errors, named lookups, boolean indices, and slice/float rejection.
File Description
test/​test_util.py Adds indexing regression tests and reorders imports.
git/​util.py Updates index dispatch to support __index__ while retaining named lookup and slice rejection.

Review effort: Balanced

@Byron
Byron merged commit 604f181 into main Oct 29, 2026
67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants