[Python-projects] Feature: ignoring some unused imports?
Dave Borowitz
dborowitz at google.com
Mon Jul 23 16:56:00 CEST 2007
Thanks for the tip. I think it still may be the case that we don't want to
require coders to explicitly disable the message, but I understand in the
general case why you wouldn't want to add this feature to pylint.
FWIW, your suggestion helped me think of another way to do it that doesn't
require changing pylint. I just inserted the check for 'import foo' in a
checker that gets run before the VariablesChecker, and call
self.linter.disable_message('W0611', 'module', line).
Thanks again.
On 7/23/07, Sylvain Thénault <sylvain.thenault at logilab.fr> wrote:
>
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.logilab.org/pipermail/python-projects/attachments/20070723/098b09dd/attachment.htm
More information about the Python-Projects
mailing list