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: 'NoneType' object has no attribute 'parent', pylint 2.5.2 #3646

Closed
HitLuca opened this issue May 26, 2020 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@HitLuca
Copy link

HitLuca commented May 26, 2020

Description

pylint keeps throwing the same error after I try to check my python project. This issue started to happen in the latest updates, but I cannot ensure that it's specific to 2.5.2

Command that reproduces the bug

The command to reproduce the issue is pylint my_project --rcfile setup.cfg. I cannot share the source code of my project.

Stacktrace

Traceback (most recent call last):
  File "/Users/user/.local/share/virtualenvs/my_project/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/Users/user/.local/share/virtualenvs/my_project/lib/python3.6/site-packages/pylint/__init__.py", line 22, in run_pylint
    PylintRun(sys.argv[1:])
  File "/Users/user/.local/share/virtualenvs/my_project/lib/python3.6/site-packages/pylint/lint/run.py", line 344, in __init__
    linter.check(args)
  File "/Users/user/.local/share/virtualenvs/my_project/lib/python3.6/site-packages/pylint/lint/pylinter.py", line 871, in check
    self.get_ast, self._iterate_file_descrs(files_or_modules)
  File "/Users/user/.local/share/virtualenvs/my_project/lib/python3.6/site-packages/pylint/lint/pylinter.py", line 904, in _check_files
    self._check_file(get_ast, check_astroid_module, name, filepath, modname)
  File "/Users/user/.local/share/virtualenvs/my_project/lib/python3.6/site-packages/pylint/lint/pylinter.py", line 930, in _check_file
    check_astroid_module(ast_node)
  File "/Users/user/.local/share/virtualenvs/my_project/lib/python3.6/site-packages/pylint/lint/pylinter.py", line 1063, in check_astroid_module
    ast_node, walker, rawcheckers, tokencheckers
  File "/Users/user/.local/share/virtualenvs/my_project/lib/python3.6/site-packages/pylint/lint/pylinter.py", line 1107, in _check_astroid_module
    walker.walk(ast_node)
  File "/Users/user/.local/share/virtualenvs/my_project/lib/python3.6/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  File "/Users/user/.local/share/virtualenvs/my_project/lib/python3.6/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  File "/Users/user/.local/share/virtualenvs/my_project/lib/python3.6/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  [Previous line repeated 1 more times]
  File "/Users/user/.local/share/virtualenvs/my_project/lib/python3.6/site-packages/pylint/utils/ast_walker.py", line 72, in walk
    callback(astroid)
  File "/Users/user/.local/share/virtualenvs/my_project/lib/python3.6/site-packages/pylint/checkers/variables.py", line 1019, in visit_name
    self._check_late_binding_closure(node, defnode)
  File "/Users/user/.local/share/virtualenvs/my_project/lib/python3.6/site-packages/pylint/checkers/variables.py", line 1722, in _check_late_binding_closure
    maybe_for = maybe_for.parent
AttributeError: 'NoneType' object has no attribute 'parent'

setup.cfg section for pylint:

[pylint]
extension-pkg-whitelist=cv2
load-plugins=
    pylint.extensions.docparams,
    pylint.extensions.mccabe
disable=
    bad-continuation,
    wrong-import-position,
    invalid-name,
    line-too-long,
    too-few-public-methods,
    import-outside-toplevel,
    logging-fstring-interpolation

pylint --version output

pylint 2.5.2
astroid 2.4.1
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 05:52:31) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
@PCManticore
Copy link
Contributor

Is it possible to minimize the source code to a reproduction example?

@PCManticore PCManticore added the Needs reproduction 🔍 Need a way to reproduce it locally on a maintainer's machine label May 28, 2020
@HitLuca
Copy link
Author

HitLuca commented May 28, 2020

Wow, I actually managed to break it down!

Here is the code that always fails (test.py)

from enum import Enum
from random import randint


class Test(Enum):
    TEST = (40, 160)

    @staticmethod
    def new_test(minimum=TEST[0], maximum=TEST[1]) -> int:
        return randint(minimum, maximum)

Command that I run:

pylint --rcfile=setup.cfg test.py

Even better, it happens without any configuration set (pylint test.py)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants