Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum: Method 'name' has no 'lower' member (no-member) #2062

Closed
geckon opened this issue May 4, 2018 · 4 comments · Fixed by #4558
Closed

Enum: Method 'name' has no 'lower' member (no-member) #2062

geckon opened this issue May 4, 2018 · 4 comments · Fixed by #4558
Labels

Comments

@geckon
Copy link

geckon commented May 4, 2018

Steps to reproduce

#! python3

from enum import Enum

class MyEnum(Enum):
    FOO = 1
    BAR = 2

    def __str__(self):
        return self.name.lower()

Run pylint on the file above.

Current behavior

E: 10,15: Method 'name' has no 'lower' member (no-member)

Expected behavior

No error. Enums have name propery which contains a string.

pylint --version output

$ pylint --version
No config file found, using default configuration
pylint 1.8.4, 
astroid 1.6.3
Python 3.4.6 (default, Mar 22 2017, 12:26:13) [GCC]
geckon added a commit to geckon/hockepy that referenced this issue May 4, 2018
Fix for #29 introduced two pylint "errors" which I believe are bugs in
pylint though. The latest pylint version 1.8.4 doesn't help though and
so I reported two issues to pylint:
pylint-dev/pylint#2062
pylint-dev/pylint#2063

Hockepy will probably have broken builds due to these false positive
pylint errors until those two issues are fixed.
@PCManticore
Copy link
Contributor

Thanks, I can reproduce this issue.

@befreeman
Copy link
Contributor

Will take a look into this tonight!

slaperche-scality added a commit to scality/metalk8s that referenced this issue Jul 15, 2019
Pylint seems to think that `name` is a method instead of a string, which
is wrong.
See pylint-dev/pylint#2062

Refs: #1410
Signed-off-by: Sylvain Laperche <sylvain.laperche@scality.com>
slaperche-scality added a commit to scality/metalk8s that referenced this issue Jul 15, 2019
Pylint seems to think that `name` is a method instead of a string, which
is wrong.
See pylint-dev/pylint#2062

Refs: #1410
Signed-off-by: Sylvain Laperche <sylvain.laperche@scality.com>
slaperche-scality added a commit to scality/metalk8s that referenced this issue Jul 16, 2019
Pylint seems to think that `name` is a method instead of a string, which
is wrong.
See pylint-dev/pylint#2062

Refs: #1410
Signed-off-by: Sylvain Laperche <sylvain.laperche@scality.com>
slaperche-scality added a commit to scality/metalk8s that referenced this issue Jul 16, 2019
Pylint seems to think that `name` is a method instead of a string, which
is wrong.
See pylint-dev/pylint#2062

Refs: #1410
Signed-off-by: Sylvain Laperche <sylvain.laperche@scality.com>
slaperche-scality added a commit to scality/metalk8s that referenced this issue Jul 18, 2019
Pylint seems to think that `name` is a method instead of a string, which
is wrong.
See pylint-dev/pylint#2062

Refs: #1410
Signed-off-by: Sylvain Laperche <sylvain.laperche@scality.com>
slaperche-scality added a commit to scality/metalk8s that referenced this issue Jul 18, 2019
Pylint seems to think that `name` is a method instead of a string, which
is wrong.
See pylint-dev/pylint#2062

Refs: #1410
Signed-off-by: Sylvain Laperche <sylvain.laperche@scality.com>
MonPote pushed a commit to scality/metalk8s that referenced this issue Jul 25, 2019
Pylint seems to think that `name` is a method instead of a string, which
is wrong.
See pylint-dev/pylint#2062

Refs: #1410
Signed-off-by: Sylvain Laperche <sylvain.laperche@scality.com>
@dineshtrivedi
Copy link

Any update on this task?

@hippo91
Copy link
Contributor

hippo91 commented Oct 22, 2020

@dineshtrivedi apparently no one has worked on this yet. Maybe @befreeman ?
Feel free to dig in and make a PR!

nelfin added a commit to nelfin/astroid that referenced this issue Jun 10, 2021
Ref pylint-dev/pylint#1932. Ref pylint-dev/pylint#2062. The enum.Enum class itself
defines two @DynamicClassAttribute data-descriptors "name" and "value"
which behave differently when looked up on an instance or on the class.
When dealing with inference of an arbitrary instance of the enum class,
e.g. in a method defined in the class body like:

    class SomeEnum(enum.Enum):
        def method(self):
            self.name  # <- here

we should assume that "self.name" is the string name of some enum
member, unless the enum itself defines a "name" member.
nelfin added a commit to nelfin/astroid that referenced this issue Jun 10, 2021
Ref pylint-dev/pylint#1932. Ref pylint-dev/pylint#2062. The enum.Enum class itself
defines two @DynamicClassAttribute data-descriptors "name" and "value"
which behave differently when looked up on an instance or on the class.
When dealing with inference of an arbitrary instance of the enum class,
e.g. in a method defined in the class body like:

    class SomeEnum(enum.Enum):
        def method(self):
            self.name  # <- here

we should assume that "self.name" is the string name of some enum
member, unless the enum itself defines a "name" member.
Pierre-Sassoulas added a commit to pylint-dev/astroid that referenced this issue Jun 13, 2021
* Add DynamicClassAttribute to list of properties

DynamicClassAttribute is a descriptor defined in Python's Lib/types.py
which changes the behaviour of an attribute depending on if it is looked
up on the class or on an instance.

* Add fake "name" property to enum.Enum subclasses

Ref pylint-dev/pylint#1932. Ref pylint-dev/pylint#2062. The enum.Enum class itself
defines two @DynamicClassAttribute data-descriptors "name" and "value"
which behave differently when looked up on an instance or on the class.
When dealing with inference of an arbitrary instance of the enum class,
e.g. in a method defined in the class body like:

    class SomeEnum(enum.Enum):
        def method(self):
            self.name  # <- here

we should assume that "self.name" is the string name of some enum
member, unless the enum itself defines a "name" member.

Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants