[Twisted-Python] Question about FileDescriptor.loseConnection() signature found by mypy

Craig Rodrigues rodrigc at crodrigues.org
Mon Jun 15 21:43:11 MDT 2020


In twisted.internet.abstract.FileDescriptor.loseConnection, the
loseConnection method
is defined like:

    def loseConnection(self,
_connDone=failure.Failure(main.CONNECTION_DONE)):

while in twisted.internet._newtls.ConnectionMixin , we have:

  def loseConnection(self):


If I run *tox -e mypy*  in trunk, mypy complains with this:

src/twisted/internet/tcp.py:204:1: error: Definition of
"loseConnection" in base class "ConnectionMixin" is incompatible with
definition in base class "FileDescriptor"  [misc]

src/twisted/internet/tcp.py:527:1: error: Definition of
"loseConnection" in base class "ConnectionMixin" is incompatible with
definition in base class "FileDescriptor"  [misc]
src/twisted/internet/tcp.py:780:1: error: Definition of
"loseConnection" in base class "ConnectionMixin" is incompatible with
definition in base class "FileDescriptor"  [misc]
src/twisted/internet/tcp.py:789:1: error: Definition of
"loseConnection" in base class "ConnectionMixin" is incompatible with
definition in base class "FileDescriptor"  [misc]

src/twisted/internet/unix.py:243:1: error: Definition of
"loseConnection" in base class "ConnectionMixin" is incompatible with
definition in base class "FileDescriptor"  [misc]
src/twisted/internet/unix.py:431:1: error: Definition of
"loseConnection" in base class "ConnectionMixin" is incompatible with
definition in base class "FileDescriptor"  [misc]


Do the signatures of loseConnection need to match in order for this to
be a valid subclass?

Is there any way to fix the code so that the mypy error goes away, or
do we need to add a comment to turn off the mypy error here?


--

Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20200615/392a6a53/attachment.htm>


More information about the Twisted-Python mailing list