Skip to content

Accept integer-like defaults in operator.length_hint - #16510

Closed
xiehuanyi wants to merge 2 commits into
python:mainfrom
xiehuanyi:fix/operator-length-hint-index-default-20261012
Closed

xiehuanyi wants to merge 2 commits into
python:mainfrom
xiehuanyi:fix/operator-length-hint-index-default-20261012

Conversation

@xiehuanyi

@xiehuanyi xiehuanyi commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

operator.length_hint accepts defaults that implement __index__, including numpy.int64, but its stub currently requires int. Use SupportsIndex for the default argument while retaining the int return type.

Regression checks were run locally; no test files are included in this PR. The existing runtime, mypy, Pyright and stubtest evidence is retained locally.

Prepared with AI assistance (Codex).

Copilot AI balanced review requested due to automatic review settings October 12, 2026 08:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

This comment has been minimized.

@srittau srittau 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.

See my comment about tests in #16511.

@xiehuanyi xiehuanyi closed this Oct 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

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.

3 participants