from
Sylvain Thénault <sylvain.thenault at logilab dot fr>
to
Benjamin Niemann <pink at odahoda dot de>
cc
Python-Projects <python-projects at lists dot logilab dot org>
subject
Re: [Python-projects] Disabling a message once
date
On Tuesday 28 June à 18:30, Benjamin Niemann wrote:2005/06/29 13:05
> On Sunday 26 June 2005 21:35, Benjamin Niemann wrote:
> > Hi,
> >
> > I think it would be nice, if I could disable a message only once for a
> > specific occurance - instead of disabling it module-wide. E.g.
> >
> > <code>
> > try:
> > ...
> > except KeyError:
> > # I'll implement error handling later
> > pass
> >
> > try:
> > ...
> > except KeyError:
> > # If key is not in dict, no action required
> > pass
> > </code>
> >
> > I would like to disable the message in the second case, but not in the
> > first one.
> > How about something like
> >
> > # pylint: disable-msg-once=W0704
> >
> > shortly before the line where the issue is detected.
> >
> > What are your thoughts about this?
> Looking at the code of pylint, I think another approach should be easier to
> implement. I propose an extended syntax for the disable-msg directive, e.g.:
>
> # pylint: disable-msg=W0704(+2)
>
> The number in brackets is either a relative line number (starting with + or -)
> or absolute (without +/-) - probably only the relative notations is useful.
> An absolute value of 0 (default, if no (NNN) is appended to the message
> code), implies the current behaviour - the message is disabled module wide.
> Otherwise the message is only disabled at the specified lines.
>
> Example:
>
> try:
> [code]
> except Exception, exc:
> # tell pylint that we know what we are doing...
> # pylint: disable-msg=W0703(-2)
> [code]
>
> A working patch is attached (no extensive testing so far, but it does not
> break the testsuite of pylint ;)
> It feels a bit like an ugly hack to me, because _module_msg_cats_state now
> contains a mix of booleans and lists...
well, I wish to be able to do such thing too, but there is two things I
don't like in this way of doing this :
- necessary to add a relative line number (I would prefer to disable for
a whole block)
- pylint has to apply the regexp one every line of every file (at least
that's what your patch is doing, I think we could reduce to every
*comment* line)
However I'm not sure how to do this cleanly, and your patch presents
some nice idea, so be sure I'll consider it.
> And another little thing: line 6 in test/fulltest.sh should be
> PYVERSIONS="2.2 2.3 2.4"
> instead of
> PYVERSIONS="2.2" "2.3" "2.4"
hum strange. That works correctly for me. This is probably due to
different shell implementation.
Regards
--
Sylvain Thénault LOGILAB, Paris (France).
http://www.logilab.com http://www.logilab.fr http://www.logilab.org
_______________________________________________
Python-Projects mailing list
Python-Projects@lists.logilab.org
http://lists.logilab.org/mailman/listinfo/python-projects
