Skip to content

astroid 2.4 / pylint 2.5: astroid error when using PyQt/Qt's QApplication #772

@The-Compiler

Description

@The-Compiler

Steps to reproduce

  1. pip install -U pip (especially with a virtualenv, so that a manylinux2014 wheel is found for PyQt rather than pip trying to build from sources)
  2. pip install pylint PyQt5
  3. Run pylint --extension-pkg-whitelist=PyQt5 keytester.py over this file:
from PyQt5.QtWidgets import QApplication
app = QApplication([])

(a pretty standard PyQt set-up)

Current behavior

Astroid fails with:

Traceback (most recent call last):
  File ".venv/bin/pylint", line 10, in <module>
    sys.exit(run_pylint())
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/__init__.py", line 22, in run_pylint
    PylintRun(sys.argv[1:])
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/lint/run.py", line 338, in __init__
    linter.check(args)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 870, in check
    self._check_files(
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 904, in _check_files
    self._check_file(get_ast, check_astroid_module, name, filepath, modname)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 930, in _check_file
    check_astroid_module(ast_node)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1062, in check_astroid_module
    retval = self._check_astroid_module(
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1107, in _check_astroid_module
    walker.walk(ast_node)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 72, in walk
    callback(astroid)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/checkers/variables.py", line 1197, in visit_importfrom
    module = self._check_module_attrs(node, module, name_parts[1:])
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/pylint/checkers/variables.py", line 1868, in _check_module_attrs
    module = next(module.getattr(name)[0].infer())
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/astroid/scoped_nodes.py", line 547, in getattr
    result = [self.import_module(name, relative_only=True)]
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/astroid/scoped_nodes.py", line 642, in import_module
    return MANAGER.ast_from_module_name(absmodname)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/astroid/manager.py", line 168, in ast_from_module_name
    return self.ast_from_module(module, modname)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/astroid/manager.py", line 262, in ast_from_module
    return AstroidBuilder(self).module_build(module, modname)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/astroid/builder.py", line 95, in module_build
    node = self.inspect_build(module, modname=modname, path=path)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/astroid/raw_building.py", line 308, in inspect_build
    self.object_build(node, module)
  File "/home/florian/tmp/pylint/.venv/lib/python3.8/site-packages/astroid/raw_building.py", line 360, in object_build
    elif hasattr(member, "__all__"):
RuntimeError: wrapped C/C++ object of type QApplication has been deleted

That exception is coming from PyQt and usually happens when Qt already deleted an object in C++, but something still holds a Python reference to it. Not sure how that can even happen with a QApplication object, though.

Expected behavior

pylint works successfully, other than the missing-module-docstring and invalid-name errors - this was the case with pylint 2.4.4 and astroid 2.3.3.

python -c "from astroid import __pkginfo__; print(__pkginfo__.version)" output

2.4.0 (and pylint 2.5.0)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions