[ZODB-Dev] importchecker and the zodb

Martijn Faassen faassen at infrae.com
Thu Feb 26 19:37:33 EST 2004


Tim Peters wrote:

>[Martijn Faassen]
>  
>
>>I have a tool called importchecker which can quite reliably detect
>>unused imports in large Python packages. It's been used successfully
>>against Zope 3.
>>
>>http://www.zope.org/Members/faassen/importchecker
>>
>>When I run it against Zope 3, I notice that the ZODB code seems to
>>contain quite a few unused imports as well. I've however refrained in
>>the past from removing these unused imports from ZODB code.
>>    
>>
>
>That's only because you know you'd get in deep trouble <wink>.
>
>  
>
Exactly. Since I just typed 'commit' I guess I'm going to be in deep 
trouble now. :)

[snip]

>>Should I run it in the ZODB tree or is it okay to run it in the Zope 3
>>tree -- are these now the same trees in CVS?
>>    
>>
>
>ZODB in ZODB HEAD and Zope3 HEAD and Zope2 HEAD are all the same now (well,
>at least so far as the core code goes).  It's best to run the tests from all
>checkouts, because the decorative addons differ, and because Zope sometimes
>does, umm, creative things with ZODB internals that are neither documented
>nor covered by the ZODB test suite.  Note too that it's important to run
>test.py with --all when changing ZODB, else the bulk of the expensive ZEO
>tests don't get run at all.  
>
Thanks for the hints. I ran the tests in Zope 2, Zope 3 and the ZODB 
package before checking in.

Some of the unused imports were false positives; in particular those 
used in doctests which the importchecker doesn't scan. Lots of the 
unused imports were in tests, which is even more harmless than another 
unused import.

In quite a few places imports that seem unused are actually wrapped in 
try .. except handlers to provide the system with fallbacks in case 
something is not available. I've left those alone. Finally I've run into 
a few cases where there seems to be a bug in the importchecker code. 
I'll investigate that later. :)

All in all, less *real* unused imports than I expected, though still 
quite a few scattered about.

Regards,

Martijn




More information about the ZODB-Dev mailing list