Skip to content

Make operator protocol operands positional-only - #16809

Merged
AlexWaygood merged 1 commit into
python:mainfrom
carljm:cjm/operator-protocol-positional-only
Nov 15, 2026
Merged

AlexWaygood merged 1 commit into
python:mainfrom
carljm:cjm/operator-protocol-positional-only

Conversation

@carljm

@carljm carljm commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

The recently-added operator module stub adds a number of new protocols with positional-or-keyword other parameters. For type checkers which fully validate signature compatibility in protocols, this means that e.g. int does not satisfy the new protocol _SupportsOr, because int.__or__ has a positional-only parameter, not a positional-or-keyword parameter named other. This causes quite a few false positives in the ecosystem.

Fix this by giving all of these protocols positional-only parameters, so they don't require keyword-call compatibility from implementations.

@github-actions

Copy link
Copy Markdown
Contributor

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

@AlexWaygood
AlexWaygood merged commit 791194c into python:main Nov 15, 2026
88 checks passed
@AlexWaygood

Copy link
Copy Markdown
Member

Thanks!

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