[Python-projects] pylint/astng feature request: namedtuple support

Vincent Legoll vincent.legoll at gmail.com
Thu Mar 26 09:22:20 CET 2009


On Thu, Mar 26, 2009 at 8:47 AM, Sylvain Thénault
<sylvain.thenault at logilab.fr> wrote:
> Le Thursday 26 March 2009 01:33:19 Maarten ter Huurne, vous avez écrit :
>> On Thursday 26 March 2009, Vincent Legoll wrote:
>> > pylint was failing to detect such cases on meld code (meld.sf.net)
>> >
>> > from misc.py:
>> >
>> > class struct(object):
>> >     """Similar to a dictionary except that members may be accessed as
>> > s.member.
>> >
>> >     Usage:
>> >     s = struct(a=10, b=20, d={"cat":"dog"} )
>> >     print s.a + s.b
>> >     """
>> >     def __init__(self, **args):
>> >         self.__dict__.update(args)
>> >     def __repr__(self):
>> >         r = ["<"]
>> >         for i in self.__dict__.keys():
>> >             r.append("%s=%s" % (i, getattr(self,i)))
>> >         r.append(">\n")
>> >         return " ".join(r)
>> >     def __cmp__(self, other):
>> >         return cmp(self.__dict__, other.__dict__)
>> >
>> > uses of instances of this class are flagged as errors
>>
>> This is indeed a similar situation. However, I think it might be very
>> difficult for astng to actually understand the code above.
>
> absolutly... I'm not sure it will ever be the case.

I understand that code being hard to understand for pylint,
but couldn't the situation be enhanced, by downgrading errors
to warnings if you see modifications to __dict__ or __getattr__
for example or something like that

-- 
Vincent Legoll


More information about the Python-Projects mailing list