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

Glyph glyph at twistedmatrix.com
Tue Jun 16 02:08:20 MDT 2020


Awesome, thanks for doing this work Craig, Adi, and Wilfredo!

-g

> On Jun 15, 2020, at 8:32 PM, Craig Rodrigues <rodrigc at crodrigues.org> wrote:
> 
> Thanks to Adi and Wilfredo who have reviewed my PR's.  Currently in trunk, I have eliminated hundreds of mypy
> errors through a combination of trivial fixes to code, adding type annotations, and adding special comments 
> to turn off mypy errors in a few places.
> 
> I have one more pending PR ( https://github.com/twisted/twisted/pull/1290 <https://github.com/twisted/twisted/pull/1290> ) to turn on a mypy build in an Azure pipeline.
> In this run of tox -e mypy there are 437 errors from mypy:
> 
> https://dev.azure.com/twistedmatrix/twisted/_build/results?buildId=1904&view=logs&j=d78da089-4bf6-58fe-28a5-46635fd5b8d1&t=45ce7910-c28c-5e9a-4ee7-e041d314a5fc <https://dev.azure.com/twistedmatrix/twisted/_build/results?buildId=1904&view=logs&j=d78da089-4bf6-58fe-28a5-46635fd5b8d1&t=45ce7910-c28c-5e9a-4ee7-e041d314a5fc>
> 
> I think we can gradually whack these down to zero mypy errors, and turn mypy on as part of default CI for Twisted.
> 
> --
> Craig
> 
> On Wed, Apr 22, 2020 at 12:28 AM Glyph <glyph at twistedmatrix.com <mailto:glyph at twistedmatrix.com>> wrote:
> 
> The first step here, however, is to set up the CI infrastructure (tox, etc) to run mypy so that we can ensure that as we start writing type hints, we don't accidentally get any of them wrong and back ourselves into any corners.  Mypy can catch a surprising number of bugs with just the implicit type-checking it does on values that come from the standard library.  In fact, if we do `mypy src/twisted` right now, and exclude the things that would be fixed by adding in https://github.com/Shoobx/mypy-zope <https://github.com/Shoobx/mypy-zope> ("method must have at least one argument" zope.interface definition errors) and fixing up some simple type hints (has no attribute "skip") we still have almost a thousand type errors that we should figure out a way to start correcting or systematically skipping if they're false positives.  I guarantee you there's at least one real bug in there though.
> 
> As you know, I tend to be pretty cautious about sweeping changes to the code that might make it harder to maintain on older versions - type hints are an exception where I think it's absolutely worthwhile to go All In early on.  But CI infrastructure for this stuff is a must-have and it might be tricky to get set up initially.
> 
> -glyph
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20200616/8a2db561/attachment.htm>


More information about the Twisted-Python mailing list