报告 PEP-544 中引入的协议的无效定义和用法。
示例:
from typing import Protocol
class MyProtocol(Protocol):
def method(self, p: int) -> str:
pass
class MyClass(MyProtocol):
def method(self, p: str) -> int: # 'method' 的类型不兼容 'MyProtocol'
pass
class MyAnotherProtocol(MyClass, Protocol): # 协议的所有基础必须为协议
pass