[code-quality] pylint reports false errors if I define a class with the name "Enumeration"
Claudiu Popa
pcmanticore at gmail.com
Sat Sep 5 16:26:18 CEST 2015
On Fri, Sep 4, 2015 at 11:20 PM, Belanger, Martin <mabelang at ciena.com> wrote:
> I'm using this version of pylint:
>
> pylint 1.3.1,
> astroid 1.2.1, common 0.62.0
> Python 2.7.9 (default, Apr 2 2015, 15:33:21)
>
>
> When I run pylint over the code below I get the error message: "E: 9, 0:
> Instance of 'MY_ENUM' has no 'blah' member (no-member)".
>
> class Enumeration(object):
> def __init__(self, name, enum_list):
> pass
>
> def blah(self):
> pass
>
> my_enum = Enumeration('MY_ENUM', [("disable", 0), ("enable", 1)])
> my_enum.blah()
>
>
> I can fix this error by enclosing [("disable", 0), ("enable", 1)] inside a
> list() or tuple(). In other words, the following fixes the problem:
>
> my_enum = Enumeration('MY_ENUM', list([("disable", 0), ("enable", 1)]))
>
> Any thoughts?
>
> Thanks,
> Martin
>
> _______________________________________________
> code-quality mailing list
> code-quality at python.org
> https://mail.python.org/mailman/listinfo/code-quality
>
Oups, this was ugly. I fixed it in astroid 1.4.0,
with https://bitbucket.org/logilab/astroid/commits/1bb9d1375f71e2ed47169982050d679ea190a29f.
Thank you for the report!
/Claudiu
More information about the code-quality
mailing list