【问题标题】:twisted.internet.interfaces.ITransport.write: Expected 0 positional argumentstwisted.internet.interfaces.ITransport.write:预期 0 个位置参数
【发布时间】: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


    【解决方案1】:

    pyright has declined to implement support for zope.interface 所以它将无法理解使用 Zope 接口编写的代码。

    【讨论】:

      猜你喜欢
      • 2022-07-25
      • 2021-12-18
      • 2021-07-27
      • 2021-05-22
      • 2021-09-17
      • 2019-11-03
      • 2020-11-27
      • 2021-09-21
      • 2022-07-20
      相关资源
      最近更新 更多