[Twisted-Python] twistedchecker now uses pylint >= 2.4.4, can we use type annotations in Twisted now?

Jean-Paul Calderone exarkun at twistedmatrix.com
Sun Jun 7 17:43:15 MDT 2020


On Sun, Jun 7, 2020 at 7:22 PM Craig Rodrigues <rodrigc at crodrigues.org>
wrote:

> I have merged a few PR's to trunk which eliminate hundreds of errors
> encountered with:
>
>
> *tox -e mypy*
> I think we can take several passes with more PR's to whack away all these
> mypy errors,
> and turn on mypy as part of the default CI for Twisted.
>
> I have seen a few errors like:
>
> src/twisted/words/protocols/jabber/sasl_mechanisms.py:47:1: error:
> 'Anonymous' is missing following 'ISASLMechanism' interface members:
> getResponse.  [misc]
>     class Anonymous(object):
> src/twisted/words/protocols/jabber/sasl_mechanisms.py:61:1: error: 'Plain'
> is missing following 'ISASLMechanism' interface members: getResponse.
>  [misc]
>     class Plain(object):
> src/twisted/internet/_dumbwin32proc.py:110:1: error: 'Process' is missing
> following 'twisted.internet.interfaces.ITransport' interface members:
> getHost, getPeer.  [misc]
>     class Process(_pollingfile._PollingTimer, BaseProcess):
> src/twisted/internet/process.py:959:1: error: 'PTYProcess' is missing
> following 'twisted.internet.interfaces.ITransport' interface members:
> getHost, getPeer.  [misc]
>     class PTYProcess(abstract.FileDescriptor, _BaseProcess):
> src/twisted/internet/process.py:959:1: error: 'PTYProcess' is missing
> following 'IProcessTransport' interface members: closeChildFD,
> writeToChild.  [misc]
>     class PTYProcess(abstract.FileDescriptor, _BaseProcess):
> src/twisted/internet/base.py:504:1: error: 'ReactorBase' is missing
> following 'IReactorCore' interface members: run.  [misc]
>     class ReactorBase(PluggableResolverMixin)
>
>
> For a class to properly implement a Zope interface, is it mandatory that
> it  implement every method in that interface?
>

Yes.


>
> If we modify the classes with mypy errors to properly implement these
> methods (even with no-ops) is that the correct
> way to go?
>

Who does this serve?  I would say no, this is not correct.  If a type
declares it implements an interface and it cannot provide useful
implementations of every method/attribute, then it made a mistake in its
declaration or the interface has the wrong methods/attributes.

Jean-Paul

>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20200607/f28513d7/attachment.htm>


More information about the Twisted-Python mailing list