-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-0-hightopic-protocols
Description
As a developer of a protocol, I don't care whether that protocol is met by an instance or a class, as long as the necessary functions and variables are present and correct. Currently it appears that only instances can satisfy a protocol.
For example, the code below attempts to meet a protocol using an instance and a class. It executes in python fine, but mypy complains that Type[Jumper1]
is not compatible with the Jumps
protocol:
from typing_extensions import Protocol
class Jumps(Protocol):
def jump(self) -> int:
pass
class Jumper1:
@classmethod
def jump(cls) -> int:
print("class jumping")
return 1
class Jumper2:
def jump(self) -> int:
print("instance jumping")
return 2
def do_jump(j: Jumps):
print(j.jump())
do_jump(Jumper1)
do_jump(Jumper2())
glyph, stereobutter, matthewvalentine, davidism, pganssle and 11 more
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-0-hightopic-protocols