Pylint: Enum: Instance of 'int' has no 'value' member (no-member)

Created on 26 Jun 2018  路  8Comments  路  Source: PyCQA/pylint

Steps to reproduce

#! python3

from enum import Enum

class BaseEnum(Enum):

    def some_behavior(self):
        pass

class MyEnum(BaseEnum):

    FOO = 1
    BAR = 2

print(MyEnum.FOO.value)

Run pylint on the above file.

Current behavior

E: 16, 0: Instance of 'int' has no 'value' member (no-member)

Expected behavior

No error.

(Subclassing an enumeration is allowed only if the enumeration does not define any members. )

pylint --version output

No config file found, using default configuration
pylint 1.9.1,
astroid 1.6.2
Python 3.6.0 (default, Apr  2 2018, 14:01:47)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)]
astroid brain bug

Most helpful comment

any update on this?
still happens in
pylint 2.6.0
astroid 2.4.2
Python 3.8.6 (default, Sep 24 2020, 22:01:47)
[GCC 9.3.0]

All 8 comments

Thank you for the report!

Notably, this affects enum.Flag and other standard classes which derive from Enum.

class Foo(enum.Flag):
    NONE = 0
    BAR = 1
    BAZ = 2

print(Foo.NONE.value)

I believe it's fixed in a recent release.

Which release?

Still happening in version 2.4.3.

Just found the issue in 2.4.4

same here, will it be updated?

any update on this?
still happens in
pylint 2.6.0
astroid 2.4.2
Python 3.8.6 (default, Sep 24 2020, 22:01:47)
[GCC 9.3.0]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elirnm picture elirnm  路  3Comments

pylint-bot picture pylint-bot  路  3Comments

GergelyKalmar picture GergelyKalmar  路  3Comments

adamtheturtle picture adamtheturtle  路  3Comments

ethanchewy picture ethanchewy  路  3Comments