from
Benjamin Niemann <pink at odahoda dot de>
to
Sylvain Thénault <sylvain.thenault at logilab dot fr>
subject
Re: [Python-projects] Disabling a message once
date
On Wednesday 29 June 2005 13:05, Sylvain Thénault wrote:2005/06/29 13:32
> On Tuesday 28 June à 18:30, Benjamin Niemann wrote:
> > 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)
This would require more knowledge of pylint's internals than I have ;)
> - 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)
Would
for (tok_type, _, start, _, line) in tokens:
if tok_type != comment:
continue
do it?
> 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.
Which shell are you using?
At least bash requires the first form - and /bin/sh is the linked to bash on
many GNU based systems.
I don't know what the original Bourne Shell syntax is, but I would be
suprised, if constructs like
CFLAGS=-g ./configure
are not portable across sh clones...
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
