Skip to content

Reject a zero step slice in PaginatedList - #3597

Merged
EnricoMi merged 5 commits into
PyGithub:mainfrom
yuefdev:fix/pagination-zero-slice-step-sol
Dec 4, 2026
Merged

EnricoMi merged 5 commits into
PyGithub:mainfrom
yuefdev:fix/pagination-zero-slice-step-sol

Conversation

@yuefdev

@yuefdev yuefdev commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Hi! issues[::0] is currently treated as issues[::1], silently iterating normally and potentially fetching pages. Python sequences reject a zero slice step with ValueError.

Reject it when constructing the slice, before iteration or any API request. Added a regression that failed before the fix.

All 40 pagination tests pass on Windows/Python 3.14; both changed files pass Ruff lint and formatting.

@EnricoMi EnricoMi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@EnricoMi EnricoMi changed the title Reject a zero step in paginated list slices Reject a zero step slice in PaginatedList Nov 17, 2026
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.10%. Comparing base (7de2644) to head (08b361c).
⚠️ Report is 106 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3597      +/-   ##
==========================================
+ Coverage   97.00%   97.10%   +0.10%     
==========================================
  Files         172      182      +10     
  Lines       18934    20627    +1693     
==========================================
+ Hits        18366    20029    +1663     
- Misses        568      598      +30     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread tests/PaginatedList.py Outdated
self.assertEqual(self.list[0].id, 4772349)
self.assertEqual(self.list[24].id, 4286936)

def testSliceWithZeroStep(self):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please move testSliceWithZeroStep down next to the other slice tests (testSliceIndexingInFirstPage / testSliceIndexingUntilEnd, around line 208).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved testSliceWithZeroStep right after testSliceIndexingUntilEnd in 08b361c.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Test Results

    10 files  ±  0      10 suites  ±0   8m 36s ⏱️ -57s
 1 270 tests + 15   1 270 ✅ + 15  0 💤 ±0  0 ❌ ±0 
17 543 runs  +105  17 542 ✅ +105  1 💤 ±0  0 ❌ ±0 

Results for commit 08b361c. ± Comparison against base commit d2d9f3b.

♻️ This comment has been updated with latest results.

@EnricoMi EnricoMi added this to the Version 2.11.0 milestone Nov 18, 2026
@cvas22

cvas22 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Looks fine to me, only Enrico's ask to move the test next to the other slice tests is still open. Side note, [::-1] yields junk and then IndexError on main too, probably worth its own issue.

@yuefdev

yuefdev commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Moved testSliceWithZeroStep right after testSliceIndexingUntilEnd in 08b361c.

@EnricoMi EnricoMi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@EnricoMi
EnricoMi enabled auto-merge December 4, 2026 14:32
@EnricoMi
EnricoMi added this pull request to the merge queue Dec 4, 2026
Merged via the queue into PyGithub:main with commit dc1e5bd Dec 4, 2026
26 of 27 checks passed
lettuce-bot Bot added a commit to lettuce-financial/github-bot-signed-commit that referenced this pull request Dec 6, 2026
This PR contains the following updates:

| Package | Change |
[Age](https://docs.renovatebot.com/merge-confidence/) |
[Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [PyGithub](https://redirect.github.com/pygithub/pygithub) | `==2.10.0`
→ `==2.11.0` |
![age](https://developer.mend.io/api/mc/badges/age/pypi/pygithub/2.11.0?slim=true)
|
![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/pygithub/2.10.0/2.11.0?slim=true)
|

---

### Release Notes

<details>
<summary>pygithub/pygithub (PyGithub)</summary>

###
[`v2.11.0`](https://redirect.github.com/PyGithub/PyGithub/releases/tag/v2.11.0)

[Compare
Source](https://redirect.github.com/pygithub/pygithub/compare/v2.10.0...v2.11.0)

#### What's Changed

##### New Features

- Add deployment branch policies to `Environment` by
[@&#8203;cvas22](https://redirect.github.com/cvas22) in
[PyGithub/PyGithub#3612](https://redirect.github.com/PyGithub/PyGithub/pull/3612)
- Add support for branch rulesets by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3617](https://redirect.github.com/PyGithub/PyGithub/pull/3617)
- Allow iterating `PaginatedList` by pages by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3603](https://redirect.github.com/PyGithub/PyGithub/pull/3603)
- Add `Organization.get_failed_invitations` by
[@&#8203;cvas22](https://redirect.github.com/cvas22) in
[PyGithub/PyGithub#3608](https://redirect.github.com/PyGithub/PyGithub/pull/3608)
- Add `Issue.transfer` to move an issue to another repository by
[@&#8203;cvas22](https://redirect.github.com/cvas22) in
[PyGithub/PyGithub#3631](https://redirect.github.com/PyGithub/PyGithub/pull/3631)
- Add `Repository.get_actions_permissions` and
`ActionsRepositoryPermissions.edit` by
[@&#8203;andrewfish0](https://redirect.github.com/andrewfish0) in
[PyGithub/PyGithub#3583](https://redirect.github.com/PyGithub/PyGithub/pull/3583)

##### Improvements

- Apply schema to `SecretScanAlert` by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3573](https://redirect.github.com/PyGithub/PyGithub/pull/3573)
- Respect application logging configuration by default by
[@&#8203;vzer200](https://redirect.github.com/vzer200) in
[PyGithub/PyGithub#3572](https://redirect.github.com/PyGithub/PyGithub/pull/3572)
- Update classes using OpenAPI spec by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3606](https://redirect.github.com/PyGithub/PyGithub/pull/3606)
- Rework rate limit support by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3602](https://redirect.github.com/PyGithub/PyGithub/pull/3602)
- Add rate limit information to `PaginatedList` pages by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3605](https://redirect.github.com/PyGithub/PyGithub/pull/3605)
- Derive `Commit.repository` from the commit url by
[@&#8203;b84330808](https://redirect.github.com/b84330808) in
[PyGithub/PyGithub#3599](https://redirect.github.com/PyGithub/PyGithub/pull/3599)
- Updating pyproject.toml by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3623](https://redirect.github.com/PyGithub/PyGithub/pull/3623)
- Fix `creator` type hint in `Repository.get_issues`
([#&#8203;3084](https://redirect.github.com/pygithub/pygithub/issues/3084))
by [@&#8203;zxc1031408077](https://redirect.github.com/zxc1031408077) in
[PyGithub/PyGithub#3598](https://redirect.github.com/PyGithub/PyGithub/pull/3598)
- Fetch `Github.oauth_scopes` on access when the scopes are not known
yet by
[@&#8203;StrikeRougeAgent](https://redirect.github.com/StrikeRougeAgent)
in
[PyGithub/PyGithub#3633](https://redirect.github.com/PyGithub/PyGithub/pull/3633)
- Reject a zero step slice in `PaginatedList` by
[@&#8203;yuefdev](https://redirect.github.com/yuefdev) in
[PyGithub/PyGithub#3597](https://redirect.github.com/PyGithub/PyGithub/pull/3597)

##### Bug Fixes

- Remove commit ref support from `Workflow.create_dispatch` by
[@&#8203;laysauchoa](https://redirect.github.com/laysauchoa) in
[PyGithub/PyGithub#2931](https://redirect.github.com/PyGithub/PyGithub/pull/2931)
- Fix listing installation repositories with user authentication by
[@&#8203;hansu650](https://redirect.github.com/hansu650) in
[PyGithub/PyGithub#3571](https://redirect.github.com/PyGithub/PyGithub/pull/3571)
- Fix `openapi.py` and `sort_class.py` for `_useAttributes` with custom
if statements by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3619](https://redirect.github.com/PyGithub/PyGithub/pull/3619)
- Keep query string when following 301 redirects by
[@&#8203;Enesuygurs](https://redirect.github.com/Enesuygurs) in
[PyGithub/PyGithub#3600](https://redirect.github.com/PyGithub/PyGithub/pull/3600)
- Allow Enterprise release asset download redirects to
`/storage/releases/` by
[@&#8203;wozhenbang2004](https://redirect.github.com/wozhenbang2004) in
[PyGithub/PyGithub#3629](https://redirect.github.com/PyGithub/PyGithub/pull/3629)
- Allow updating hooks without resending configuration by
[@&#8203;wozhenbang2004](https://redirect.github.com/wozhenbang2004) in
[PyGithub/PyGithub#3630](https://redirect.github.com/PyGithub/PyGithub/pull/3630)
- Fix `PaginatedList.total_count` for custom `toal_count_item` by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3648](https://redirect.github.com/PyGithub/PyGithub/pull/3648)

##### Maintenance

- Generate a GraphQL API reference from method annotations by
[@&#8203;lzyrtxtp](https://redirect.github.com/lzyrtxtp) in
[PyGithub/PyGithub#3585](https://redirect.github.com/PyGithub/PyGithub/pull/3585)
- Replace `black`, `pyupgrade`, and `docformatter` with `ruff` by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3592](https://redirect.github.com/PyGithub/PyGithub/pull/3592)
- Add ruff reformat commit to .git-blame-ignore-revs by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3593](https://redirect.github.com/PyGithub/PyGithub/pull/3593)
- Fix logging tests by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3594](https://redirect.github.com/PyGithub/PyGithub/pull/3594)
- Replace responses with vcrpy by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3563](https://redirect.github.com/PyGithub/PyGithub/pull/3563)
- Restrict workflow permissions by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3611](https://redirect.github.com/PyGithub/PyGithub/pull/3611)
- Fix syntax error in code scanning alert example by
[@&#8203;puhupwasbind301](https://redirect.github.com/puhupwasbind301)
in
[PyGithub/PyGithub#3607](https://redirect.github.com/PyGithub/PyGithub/pull/3607)
- Clarify that Repository.get_commit accepts any ref by
[@&#8203;cvas22](https://redirect.github.com/cvas22) in
[PyGithub/PyGithub#3609](https://redirect.github.com/PyGithub/PyGithub/pull/3609)
- Document refreshing cached objects with update by
[@&#8203;yuefdev](https://redirect.github.com/yuefdev) in
[PyGithub/PyGithub#3596](https://redirect.github.com/PyGithub/PyGithub/pull/3596)
- Pin tox below 4.67.14 in CI by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3620](https://redirect.github.com/PyGithub/PyGithub/pull/3620)
- Test built whl package in CI by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3624](https://redirect.github.com/PyGithub/PyGithub/pull/3624)
- Document GitHub App client IDs for AppAuth by
[@&#8203;akoroderdeniteenfeld-sudo](https://redirect.github.com/akoroderdeniteenfeld-sudo)
in
[PyGithub/PyGithub#3637](https://redirect.github.com/PyGithub/PyGithub/pull/3637)
- Show how to read an annotated tag message by
[@&#8203;akoroderdeniteenfeld-sudo](https://redirect.github.com/akoroderdeniteenfeld-sudo)
in
[PyGithub/PyGithub#3643](https://redirect.github.com/PyGithub/PyGithub/pull/3643)
- Clarify which object cancels an organization invitation by
[@&#8203;akoroderdeniteenfeld-sudo](https://redirect.github.com/akoroderdeniteenfeld-sudo)
in
[PyGithub/PyGithub#3645](https://redirect.github.com/PyGithub/PyGithub/pull/3645)
- Obfuscate OpenAPI test diff line context by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3647](https://redirect.github.com/PyGithub/PyGithub/pull/3647)
- Add OpenAPI script tests around anyof by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3613](https://redirect.github.com/PyGithub/PyGithub/pull/3613)
- Fixing rst and md formatting issues by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3622](https://redirect.github.com/PyGithub/PyGithub/pull/3622)
- Fix VCR replay matching by
[@&#8203;EnricoMi](https://redirect.github.com/EnricoMi) in
[PyGithub/PyGithub#3646](https://redirect.github.com/PyGithub/PyGithub/pull/3646)
- Add `noRecord()` to reuse replay data when recording by
[@&#8203;cvas22](https://redirect.github.com/cvas22) in
[PyGithub/PyGithub#3618](https://redirect.github.com/PyGithub/PyGithub/pull/3618)

**Full Changelog**:
<PyGithub/PyGithub@v2.10.0...v2.11.0>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/lettuce-financial/github-bot-signed-commit).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NS4xMi4wIiwidXBkYXRlZEluVmVyIjoiNDUuMTIuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants