[Python-projects] E1101 and dynamically generated attributes

Sylvain Thénault sylvain.thenault at logilab.fr
Mon Jul 16 08:31:47 CEST 2007


On Friday 13 July à 18:26, Maarten ter Huurne wrote:
> syt at logilab.fr wrote on 2007-07-13 11:29:37 AM:
> 
> > On Thursday 12 July à 13:29, Maarten ter Huurne wrote:
> > > class ClassWithDynamicAttributes(object):
> > >     # pylint: disable-msg=E1101
> > >
> > >     # (rest of class definition)
> > >
> [stupid Lotus Notes did not preserve the indentation when sending HTML e-mail]
> > >
> > > This would mean that any missing attributes on ClassWithDynamicAttributes
> or
> > > any of its subclasses do not lead to E1101 being issued.
> > >
> > > Does this approach make sense?
> > > If so, I am willing to try and implement this; do you have any hints where
> I
> > > should start?
> >
> > that would be nice indeed. The problem is that currently messages
> > disabling implementation is done according to source line numbers, not
> > python objects, and I think it should be done that way to allow that
> > kind of functionnality :(
> 
> It is already possible to silence warnings in a block scope, like this:
> 
> def f():
>     # pylint: disable-msg=E1234
>    
>     # (rest of function definition)
> 
> How is this implemented? I had hoped it would add some kind of property to the
> function object.
> 
> Maybe it does not work like that though and it only supresses the warning if it
> is encountered while parsing the current block? That would explain why
> sometimes the block-level suppression does not seem to work: some warnings may
> be issued at a later time, when that block is no longer the current block.
 
it's implemented on a line nummbering basis: a global structure
initialized for each module before its analysis is containing msg id and
line numbers where it's deactivated. Refactor this to get it as a
property of the ast nodes would probably be much more nice (and easiest
then to implement ideas such as yours).
-- 
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