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

AttributeError: 'ClassDef' object has no attribute 'value' #6366

Closed
dickreuter opened this issue Dec 9, 2020 · 3 comments · Fixed by #6367
Closed

AttributeError: 'ClassDef' object has no attribute 'value' #6366

dickreuter opened this issue Dec 9, 2020 · 3 comments · Fixed by #6367
Assignees
Labels
Crash 💥 A bug that makes pylint crash
Milestone

Comments

@dickreuter
Copy link
Contributor

Running the latest version of pylint (2.6, and also with 2.4.4), I get this error:

astroid/bases.py:113: AttributeError: 'ClassDef' object has no attribute 'value'

Any suggestions on what could be causing it would be greatly appreciated.

@hippo91
Copy link
Contributor

hippo91 commented Dec 12, 2020

@dickreuter thanks for your report. Could you please follow the issue template submission so that we have at least a small piece of code to start with?

@dickreuter
Copy link
Contributor Author

The issue only occurred when the folder with the venv was included in the scanned files.

@jacobtylerwalls
Copy link
Member

The issue only occurred when the folder with the venv was included in the scanned files.

I reproduced a similar failure in this scenario, linting a file from cryptography (part of the venv's packages). I reduced the example to this. Failure looks to be in pylint's _supports_protocol_method() util.

class Extensions:
    def get_extension_for_oid(self):
        for _ in self:
            pass

    __len__, __iter__ = lambda x: x
Traceback (most recent call last):
  File "/Users/.../pylint/pylint/lint/pylinter.py", line 1130, in _check_files
    self._check_file(get_ast, check_astroid_module, file)
  File "/Users/.../pylint/pylint/lint/pylinter.py", line 1165, in _check_file
    check_astroid_module(ast_node)
  File "/Users/.../pylint/pylint/lint/pylinter.py", line 1317, in check_astroid_module
    retval = self._check_astroid_module(
  File "/Users/.../pylint/pylint/lint/pylinter.py", line 1364, in _check_astroid_module
    walker.walk(node)
  File "/Users/.../pylint/pylint/utils/ast_walker.py", line 76, in walk
    self.walk(child)
  File "/Users/.../pylint/pylint/utils/ast_walker.py", line 76, in walk
    self.walk(child)
  File "/Users/.../pylint/pylint/utils/ast_walker.py", line 76, in walk
    self.walk(child)
  File "/Users/.../pylint/pylint/utils/ast_walker.py", line 73, in walk
    callback(astroid)
  File "/Users/.../pylint/pylint/checkers/typecheck.py", line 2060, in visit_for
    self._check_iterable(node.iter)
  File "/Users/.../pylint/pylint/checkers/typecheck.py", line 2044, in _check_iterable
    if not is_iterable(inferred, check_async=check_async):
  File "/Users/.../pylint/pylint/checkers/utils.py", line 1177, in is_iterable
    return _supports_protocol(value, protocol_check)
  File "/Users/.../pylint/pylint/checkers/utils.py", line 1153, in _supports_protocol
    if protocol_callback(value):
  File "/Users/.../pylint/pylint/checkers/utils.py", line 1096, in _supports_iteration_protocol
    return _supports_protocol_method(value, ITER_METHOD) or _supports_protocol_method(
  File "/Users/.../pylint/pylint/checkers/utils.py", line 1070, in _supports_protocol_method
    if isinstance(first.parent.value, nodes.Const):
  File "/Users/.../astroid/astroid/bases.py", line 111, in __getattr__
    return getattr(self._proxied, name)
AttributeError: 'ClassDef' object has no attribute 'value'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash 💥 A bug that makes pylint crash
Projects
None yet
3 participants