[Python-projects] E1101 and dynamically generated attributes
Sylvain Thénault
sylvain.thenault at logilab.fr
Fri Jul 13 11:29:37 CEST 2007
On Thursday 12 July à 13:29, Maarten ter Huurne wrote:
> Hi,
>
> Because PyLint analyses the code statically, it does not know about attributes
> created with setattr. As a result, it emits E1101 messages when such a
> dynamically created attribute is accessed.
>
> Currently, I know of only two ways to silence those messages:
> - turn off E1101 completely:
> I don't like this, because in general it's a very useful message.
> - turn off E1101 for every attribute accessed:
> I don't like this either, because there are many such accesses.
>
> An possible alternative would be to turn off E1101 for a particular class, like
> this:
>
> class ClassWithDynamicAttributes(object):
> # pylint: disable-msg=E1101
>
> # (rest of class definition)
>
> 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 :(
--
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