Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1962,6 +1962,9 @@ def check_reverse_op_method(

assert defn.info

if defn.info.is_protocol:
return

# First check for a valid signature
method_type = CallableType(
[AnyType(TypeOfAny.special_form), AnyType(TypeOfAny.special_form)],
Expand Down
11 changes: 11 additions & 0 deletions test-data/unit/check-protocols.test
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,17 @@ f(C()) # E: No overload variant of "f" matches argument type "C" \
[builtins fixtures/isinstance.pyi]
[typing fixtures/typing-full.pyi]

[case testProtocolReversePowWithModulo]
from typing import overload, Protocol

class PowableProto(Protocol):
@overload
def __rpow__(self, other: "PowableProto") -> "PowableProto": ...
@overload
def __rpow__(
self, other: "PowableProto", modulo: "PowableProto"
) -> "PowableProto": ...

-- Unions of protocol types
-- ------------------------

Expand Down
Loading