Skip to content

Allow reverse operator methods on protocols#21538

Open
Will-thom wants to merge 1 commit into
python:masterfrom
Will-thom:fix-protocol-rpow-signature
Open

Allow reverse operator methods on protocols#21538
Will-thom wants to merge 1 commit into
python:masterfrom
Will-thom:fix-protocol-rpow-signature

Conversation

@Will-thom
Copy link
Copy Markdown

Fixes #10786.

Summary

  • Skip reverse-operator signature and overlap checks for protocol definitions, matching their structural typing role rather than concrete runtime dispatch.
  • Add regression coverage for a Protocol defining overloaded rpow with a modulo argument.

Tests

  • ..venv\Scripts\pytest.exe mypy/test/testcheck.py::TypeCheckSuite::check-protocols.test -q
  • ..venv\Scripts\pytest.exe mypy/test/testcheck.py::TypeCheckSuite::check-classes.test -q

@github-actions
Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of 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.

Mypy signals error with Protocol and __rpow__ method with three arguments

1 participant