【发布时间】:2023-02-10 21:34:49
【问题描述】:
这是我的代码:
from twisted.protocols.basic import LineReceiver
from twisted.internet.interfaces import ITransport
class AbcProtocol(LineReceiver):
transport: ITransport
def lineReceived(self, line: bytes) -> None:
self.transport.write(line)
然后,我收到了来自 pyright 的警告:8 col 34-44 error| [Pyright reportGeneralTypeIssues] Expected 0 positional arguments [E]
我认为,Pyright 认为第一个参数只是 self,我不应该传递 self 参数。
有没有办法让pyright明白第一个参数不是self?
还是我的理解有问题?
ITransport 是这样的:
class ITransport(Interface):
def write(data: bytes) -> None: ...
第一个参数不是self。
在zope.interface document的例子中,第一个参数不是self。
我预计 pyright 不会生成任何警告并理解第一个参数。
【问题讨论】:
标签: python-3.x twisted pyright zope.interface