[IronPython] Pyflakes on IronPython

Sanghyeon Seo sanxiyn at gmail.com
Sun Dec 31 05:41:20 CET 2006


On June 22, Michael Foord wrote:

"At Resolver we are looking into tools that we can use to provide
simple code hygiene checks. Check we're not shadowing built-in names,
check for unneeded import statements and unused variables; that sort
of thing.

I know of three Python modules that do this. They all fail
unredeemably on  IronPython: (snip)

Pyflakes: Uses compiler.parse."

This is also CodePlex issue #563, titled "Support for Code Quality Tools".
http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=563

In the release note of IPCE r5, I wrote:

"Experimental AST support."

For those who don't know, compiler.parse() returns AST, so they are
the same thing.

I am happy to announce that FePy's AST support got out of experimental
status, and is now mature enough to run Pyflakes without much trouble.
Actually, I ran it over FePy libraries and fixed a couple of unused
.NET imports!

This is done by "AST transform", which transforms AST made of
subclasses of IronPython.Compiler.Ast.Node to AST made of subclasses
of Python's compiler.ast.Node. Technical details will be discussed in
the separate mail.

Here's a demo:

tinuviel at debian:~/svn/fepy$ ipy /usr/bin/pyflakes trunk/lib
trunk/lib/_pth_support.py:116: 'sitecustomize' imported but unused
trunk/lib/socket.py:222: 'ssl' imported but unused
trunk/lib/socket.py:227: '_fileobject' imported but unused

(These warnings are all true, but sitecustomize import is for the side
effect, and ssl/_fileobject is part of external API.)

Enjoy!

-- 
Seo Sanghyeon



More information about the Ironpython-users mailing list