Remove unused variables and module imports

Bug #677751 reported by alan runyan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ZODB
Fix Released
Undecided
Unassigned

Bug Description

If you run pyflakes on the latest version of ZODB there are dozens of modules which are imported but not used. There are also several variables which are defined but not used. Looks like a fairly simple task.

Revision history for this message
Danny Navarro (jdnavarro) wrote :

I'm trying to remove all unused imports but I'm still getting some errors and failures in the tests.

I've seen sometimes:

import ZODB
import ZODB.tests
import ZODB.interfaces
...

The easiest would be leave just ZODB import and delete the rest, but I'm pretty sure there must be a reason to make imports more explicit.

Revision history for this message
Danny Navarro (jdnavarro) wrote :

I also noticed that some imports are not directly used within the module but imported elsewhere. Some of those modules are commented as being there for backwards compatibility but there are still some without that comment. So just running pyflakes won't give which imports are not really unused.

Revision history for this message
Danny Navarro (jdnavarro) wrote :

Here I attach the patch removing the unused imports. All the tests passed but you should watch out for the compatibility issues mentioned above if they are not covered by tests.

I didn't mess up with BTrees package because it's too difficult for me.

I didn't look into unused variables yet.

Revision history for this message
Jim Fulton (jim-zope) wrote : Re: [Bug 677751] Re: Remove unused variables and module imports

On Mon, Nov 22, 2010 at 6:55 AM, Danny Navarro <email address hidden> wrote:
> I'm trying to remove all unused imports but I'm still getting some
> errors and failures in the tests.
>
> I've seen sometimes:
>
> import ZODB
> import ZODB.tests
> import ZODB.interfaces
> ...
>
> The easiest would be leave just ZODB import and delete the rest, but I'm
> pretty sure there must be a reason to make imports more explicit.

pyflakes fails on imports. It suggests imports are unnecessary when
they are very necessary.

Jim

--
Jim Fulton

Revision history for this message
Jim Fulton (jim-zope) wrote :

Thanks.

I ended up reviewing the patch line by line, as many of the imports proposed for removal
were in fact needed.

Changed in zodb:
status: New → Fix Committed
Jim Fulton (jim-zope)
Changed in zodb:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.