[Python-projects] Feature: ignoring some unused imports?
Sylvain Thénault
sylvain.thenault at logilab.fr
Mon Jul 23 10:58:12 CEST 2007
On Friday 20 July à 17:42, Dave Borowitz wrote:
> Hello again Logliab folks,
Hey,
> 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?
you can just use the inline messages disabling feature for this, eg ::
import foo # pylint: disable-msg=W0611
that should do the trick
--
Sylvain Thénault LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian: http://www.logilab.fr/formations
Développement logiciel sur mesure: http://www.logilab.fr/services
Python et calcul scientifique: http://www.logilab.fr/science
More information about the Python-Projects
mailing list