-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
pylint has issues with IntEnum.name type detection #1932
Labels
Comments
Thanks for the report @jleclanche It still amazes me how much weird stuff goes around in |
Reproducible for a plain |
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.
2 tasks
nelfin
added a commit
to nelfin/pylint
that referenced
this issue
Jun 10, 2021
4 tasks
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 <[email protected]>
nelfin
added a commit
to nelfin/pylint
that referenced
this issue
Jun 13, 2021
cdce8p
pushed a commit
that referenced
this issue
Jun 16, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to reproduce
pylint -dC test.py
with the file aboveOutput:
pylint --version output
pylint 1.8.2,
astroid 1.6.1
Python 3.6.4 (default, Jan 5 2018, 02:35:40)
[GCC 7.2.1 20171224]
The text was updated successfully, but these errors were encountered: