[Python-projects] Feature: ignoring some unused imports?

Dave Borowitz dborowitz at google.com
Fri Jul 20 23:42:06 CEST 2007


Hello again Logliab folks,

If there's another public forum where I should talk about pylint feature
requests, please let me know.

Without going into too much detail, in our programming environment we have a
package (call it 'foo') whose __init__.py has some side effects that enable
other modules to be found. This means that we have a lot of code like this:
import foo
from bar import baz

where 'import foo' is required because it fixes things so bar can be found.
However, in some cases, that's the _only_ thing the foo package is used for,
so pylint understandably thinks it's unused. It looks to me like there is no
way to turn of the check for unused imports for a fixed set of names, and
the check is sufficiently complicated that I don't want to rewrite it in a
plugin just for that. So, I made this little patch (attached) to add an
"ignore-unused-imports" option that takes a list of names that should be
ignored if they're unused.

I guess I have two questions:
1. Is there some easy way of doing this that doesn't involve patching
pylint?
2. If not, is this an ok feature to add for everyone?

Thanks,
Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.logilab.org/pipermail/python-projects/attachments/20070720/72e9df25/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pylint-ignore-unused.patch
Type: text/x-patch
Size: 1248 bytes
Desc: not available
Url : http://lists.logilab.org/pipermail/python-projects/attachments/20070720/72e9df25/attachment.bin 


More information about the Python-Projects mailing list