Repository navigation
fix/iterable list index protocol - #2326
Merged
Merged
Conversation
`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
force-pushed
the
fix/iterable-list-index-protocol
branch
from
October 29, 2026 16:58
37a1f4f to
451a526
Compare
Contributor
There was a problem hiding this comment.
🟢 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersede #2322