Type checking tools for Python 2?
tjreedy at udel.edu
Tue Apr 21 21:26:25 CEST 2015
On 4/21/2015 3:11 PM, Skip Montanaro wrote:
> On Tue, Apr 21, 2015 at 1:29 PM, Terry Reedy <tjreedy at udel.edu> wrote:
>> I believe mypy can typecheck 2.x code in conjunction with stub files.
I based this on comments in the PEP 484 discussion on py-dev, which I
might have misread as being about now rather than the future. Or maybe
the comment was about something other than mypy. Google's python
typechecker is certainly targeting 2.7, since that is what they are
using. I do not know if they will release it publicly.
> Thanks. Maybe the MyPy FAQ is just out-of-date? It includes this Q&A:
> All of my code is still in Python 2. What are my options?
> Mypy currently supports Python 3 syntax. Python 2 support is still
> in early stages of development. However, Python 2 support will be
> improving. Mypy includes a custom codec that lets you use Python 3
> function annotations in Python 2 code. The codec just removes the
> annotations before bytecode compilation.
> Unless I misread the first couple sentences of the answer, it seems
> that it can't actually grok Python 2 code. I'm not sure what to make
> of the statement about a "custom codec" and how that would relate to
> function annotations.
Sorry if I jumped the gun on mypy.
Terry Jan Reedy
More information about the Python-list