[Python-projects] Pylint ignore line/block

Sylvain =?UTF-8?Q?Th=E9nault?= sylvain.thenault at logilab.fr
Mon Oct 29 10:09:31 CET 2007


On Mon, Oct 29, 2007 at 09:05:54AM +0100, Alexandre Fayolle wrote:
> Forwarding a message received via private mail but which is relevant to
> the list 
> 
> ----- Forwarded message from Brent Marshall -----
> 
> From: Brent Marshall 
> To: sylvain.thenault at logilab.fr
> Cc: alexandre.fayolle at logilab.fr, Chris Hobbs
> Date: Thu, 25 Oct 2007 08:44:25 -0400
> Subject: Pylint ignore line/block
> 
> Good day,
> 
>     I was trying to find a way to make Pylint ignore a particular error
> or warning for a particular line, and came across the following email in
> your archives (http://www.logilab.org/email/1878), which seems to
> indicate that this isn't possible.  However, the email is a couple of
> years old, so I wondered whether that was still the case.
> 
>     Sylvain, in your response to Alexandre, you indicated that you were
> looking for a clean way to add such a feature.  I have a suggestion that
> may be acceptable:
> 
>     Perhaps a comment with a special flag, indicating the specific
> errors which are to be ignored for the following line.  For example:
> 
> #!<Pylint ignore=W0702>
> 
>     Another feature which would be useful would be the ability to change
> particular messages to different severities (Error/Warning/Info).  For
> example, W0702 flags a condition which I would like to allow, but which
> I would like flagged as "Info"
> 
>     My objective is to configure Pylint so that I get zero
> Error/Warnings in my code for conditions I consider acceptable.  That
> way, I won't get into the habit of ignoring warnings, and miss an
> important one.

Even if it has some caveats, I think the current inline message
disabling feature could do the trick for you: 

# pylint: disable-msgs=E0101,W0133

will disable listed message for the following block of code. Putting it
at the end of a line of code will disable messages for this line only.
Hope that helps

-- 
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