python-3.xtwistedpyrightzope.interface

twisted.internet.interfaces.ITransport.write: Expected 0 positional arguments


This is my code:

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)

Then, I got a warning from pyright:
8 col 34-44 error| [Pyright reportGeneralTypeIssues] Expected 0 positional arguments [E]
I think, Pyright think the first parameter is just self and I shouldn't pass the self parameter.
Is there a way to let pyright understand the first parameter isn't self?
Or is there something wrong with my understanding?


The ITransport like this:

class ITransport(Interface):
    def write(data: bytes) -> None: ...

The first parameter is not self.
In examples of zope.interface document, the first parameter is not self.


I expected pyright doesn't generate any warning and understand first parameter.


Solution

  • pyright has declined to implement support for zope.interface so it will not be able to understand code written using Zope interfaces.