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
"AttributeError: 'ClassDef' object has no attribute 'value'" in _check_redefined_slots #6100
Comments
Thanks for the report. Regression in 56129b7. /CC @mbyrnepr2 |
Thanks for the headsup. By the way, this example is invalid Python: $ python example.py
Traceback (most recent call last):
File "example.py", line 1, in <module>
class MyClass:
TypeError: __slots__ items must be strings, not 'type' But we probably want to avoid the crash either way. |
I’m on mobile now but I can update the example using enums which I think mapped to strings. Will check later. |
Enum example: from enum import Enum
class MyEnum(Enum):
VALUE = 'value'
class MyClass:
__slots__ = [MyEnum.VALUE] |
Thanks for this example. This one is also invalid Python but I agree that we could tidy things up to prevent the crash report which happens when running Pylint on it. Both of the examples provided emit the
Traceback (most recent call last):
File "example2.py", line 6, in <module>
class MyClass:
TypeError: __slots__ items must be strings, not 'MyEnum' |
Thanks. So I realized that enum example doesn't yet match the code base because the issues come from code that uses a custom Enum (added pre-Python 3). So in those cases, the value is a string, not an enum value. |
Bug description
I'm seeing this exception when a
__slot__
is set to a list of enum values, but was able to reproduce minimally with just using a type as the list:Configuration
No response
Command used
Pylint output
Expected behavior
pylint not crash.
Pylint version
OS / Environment
Python 3.8.8
macOS 11.6.4
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: