On 6/15/20 11:43 PM, Craig Rodrigues wrote:

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?

Not directly related, but I ran into a similar issue [1] with the "connectionLost" method in the HTTP2 code including an additional parameter. In this case it seems to be used to pass around additional state and follows a similar pattern (of the additional parameter being prefixed with an underscore). I'll be curious what the proper way to deal with this is!

--Patrick

[1]: https://github.com/twisted/twisted/pull/1265#issuecomment-641512616

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to