Skip to content

Support start and stop bounds in BarrelList.index - #592

Closed
lohitredddy wants to merge 1 commit into
mahmoud:masterfrom
lohitredddy:fix-barrellist-index-bounds
Closed

lohitredddy wants to merge 1 commit into
mahmoud:masterfrom
lohitredddy:fix-barrellist-index-bounds

Conversation

@lohitredddy

@lohitredddy lohitredddy commented Oct 19, 2026 •

Copy link
Copy Markdown

The change

Support the optional start and stop arguments in BarrelList.index(), matching the documented list-compatible API. For example, BarrelList([1, 2, 1]).index(1, 1) currently raises TypeError instead of returning 2. The fix handles negative bounds and integer-index objects without flattening the internal lists.

Regression tests compare 800 bounded searches against list.index(). All three new test cases fail before the fix. Full tests and doctests on Python 3.12: 682 passed, 12 subtests passed. Targeted Ruff checks and git diff --check also pass. Other Python versions and upstream CI are unverified.

The backstory

I’m starting to contribute to smaller Python projects and wanted a concrete compatibility fix. This was found through an assisted source review, rather than a production incident.

AI assistance

  • Harness/tooling: Codex, for investigation, implementation, tests, and this description.
  • Model: GPT-6.

@mahmoud

mahmoud commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Folded into #609 (see the PR description for credit). Thanks for the report and the repro.

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.

2 participants