pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.24k stars 1.12k forks source link

'str' object has no attribute 'parent' #6221

Closed edreamleo closed 2 years ago

edreamleo commented 2 years ago

Bug description

Note: Crash appeared several times in different files. Including all of pylint-crash-2022-04-07-07.txt made the body text of this issue too big.

pylint crashed with a AttributeError and with the following stacktrace:

Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\lint\pylinter.py", line 1124, in _check_files
    self._check_file(get_ast, check_astroid_module, file)
  File "c:\leo.repo\ekr-pylint\pylint\lint\pylinter.py", line 1159, in _check_file
    check_astroid_module(ast_node)
  File "c:\leo.repo\ekr-pylint\pylint\lint\pylinter.py", line 1311, in check_astroid_module
    retval = self._check_astroid_module(
  File "c:\leo.repo\ekr-pylint\pylint\lint\pylinter.py", line 1358, in _check_astroid_module
    walker.walk(node)
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 76, in walk
    self.walk(child)
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 76, in walk
    self.walk(child)
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 76, in walk
    self.walk(child)
  [Previous line repeated 3 more times]
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'

Note Several more similar crashes appear in the crash report.

Configuration

No response

Command used

A script containing the following:

is_win = sys.platform.startswith('win')
args =  ','.join([f"'--rcfile={rc_fn}'", f"'{fn}'"])
if is_win:
    args = args.replace('\\','\\\\')
command = f'{sys.executable} -c "from pylint import lint; args=[{args}]; lint.Run(args)"'
if not is_win:
    command = shlex.split(command)
proc = subprocess.Popen(command, shell=False)
proc.communicate()

Pylint output

C:\leo.repo\leo-editor>python -m pylint-leo -a

C:\leo.repo\leo-editor>echo off

pylint-leo: skip C:/leo.repo/leo-editor/leo/plugins/freewin.py
pylint: 254 files
................************* Module leo.commands.killBufferCommands
leo\commands\killBufferCommands.py:334:16: C2801: Unnecessarily calls dunder method __next__. Use next built-in function. (unnecessary-dunder-call)
........Exception on node <Attribute.connect l.98 at 0x21c63728a60> in file 'C:\leo.repo\leo-editor\leo\core\leoBackground.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.core.leoBackground
leo\core\leoBackground.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\core\leoBackground.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-06.txt'. (fatal)
....************* Module leo.core.leoCache
leo\core\leoCache.py:353:12: C2801: Unnecessarily calls dunder method __delitem__. Use del keyword. (unnecessary-dunder-call)
....************* Module leo.core.leoCommands
leo\core\leoCommands.py:4164:16: C2801: Unnecessarily calls dunder method __next__. Use next built-in function. (unnecessary-dunder-call)
..........************* Module leo.core.leoGlobals
leo\core\leoGlobals.py:398:15: C2801: Unnecessarily calls dunder method __hash__. Use hash built-in function. (unnecessary-dunder-call)
leo\core\leoGlobals.py:645:15: C2801: Unnecessarily calls dunder method __lt__. Use < operator. (unnecessary-dunder-call)
leo\core\leoGlobals.py:645:37: C2801: Unnecessarily calls dunder method __eq__. Use == operator. (unnecessary-dunder-call)
leo\core\leoGlobals.py:648:19: C2801: Unnecessarily calls dunder method __eq__. Use == operator. (unnecessary-dunder-call)
leo\core\leoGlobals.py:651:19: C2801: Unnecessarily calls dunder method __lt__. Use < operator. (unnecessary-dunder-call)
leo\core\leoGlobals.py:651:46: C2801: Unnecessarily calls dunder method __eq__. Use == operator. (unnecessary-dunder-call)
leo\core\leoGlobals.py:654:19: C2801: Unnecessarily calls dunder method __lt__. Use < operator. (unnecessary-dunder-call)
leo\core\leoGlobals.py:659:15: C2801: Unnecessarily calls dunder method __hash__. Use hash built-in function. (unnecessary-dunder-call)
leo\core\leoGlobals.py:2255:12: C2801: Unnecessarily calls dunder method __setattr__. Set attribute directly or use setattr built-in function. (unnecessary-dunder-call)
leo\core\leoGlobals.py:2299:12: C2801: Unnecessarily calls dunder method __setattr__. Set attribute directly or use setattr built-in function. (unnecessary-dunder-call)
........************* Module leo.core.leoNodes
leo\core\leoNodes.py:225:19: C2801: Unnecessarily calls dunder method __eq__. Use == operator. (unnecessary-dunder-call)
leo\core\leoNodes.py:239:15: C2801: Unnecessarily calls dunder method __eq__. Use == operator. (unnecessary-dunder-call)
leo\core\leoNodes.py:239:37: C2801: Unnecessarily calls dunder method __gt__. Use > operator. (unnecessary-dunder-call)
leo\core\leoNodes.py:242:15: C2801: Unnecessarily calls dunder method __eq__. Use == operator. (unnecessary-dunder-call)
leo\core\leoNodes.py:242:37: C2801: Unnecessarily calls dunder method __lt__. Use < operator. (unnecessary-dunder-call)
leo\core\leoNodes.py:245:19: C2801: Unnecessarily calls dunder method __eq__. Use == operator. (unnecessary-dunder-call)
leo\core\leoNodes.py:245:46: C2801: Unnecessarily calls dunder method __gt__. Use > operator. (unnecessary-dunder-call)
leo\core\leoNodes.py:1943:16: C2801: Unnecessarily calls dunder method __next__. Use next built-in function. (unnecessary-dunder-call)
...Exception on node <Attribute.connect l.288 at 0x1f0231fe1a0> in file 'C:\leo.repo\leo-editor\leo\core\leoPrinting.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.core.leoPrinting
leo\core\leoPrinting.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\core\leoPrinting.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-06.txt'. (fatal)
...............************* Module leo.core.leoserver
leo\core\leoserver.py:783:16: C2801: Unnecessarily calls dunder method __next__. Use next built-in function. (unnecessary-dunder-call)
..************* Module leo.external.leosax
leo\external\leosax.py:63:23: C2801: Unnecessarily calls dunder method __str__. Use str built-in function. (unnecessary-dunder-call)
..Exception on node <Attribute.connect l.67 at 0x1d0d133f490> in file 'C:\leo.repo\leo-editor\leo\plugins\QNCalendarWidget.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.QNCalendarWidget
leo\plugins\QNCalendarWidget.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\QNCalendarWidget.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
.......Exception on node <Attribute.connect l.442 at 0x1194ed9a200> in file 'C:\leo.repo\leo-editor\leo\plugins\attrib_edit.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.attrib_edit
leo\plugins\attrib_edit.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\attrib_edit.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
.....Exception on node <Attribute.connect l.122 at 0x272e973be80> in file 'C:\leo.repo\leo-editor\leo\plugins\bigdash.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.bigdash
leo\plugins\bigdash.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\bigdash.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
.........................................................................Exception on node <Attribute.connect l.97 at 0x23362a698d0> in file 'C:\leo.repo\leo-editor\leo\plugins\livecode.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.livecode
leo\plugins\livecode.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\livecode.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
.................Exception on node <Attribute.connect l.83 at 0x22d8f79bac0> in file 'C:\leo.repo\leo-editor\leo\plugins\nested_splitter.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.nested_splitter
leo\plugins\nested_splitter.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\nested_splitter.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
....Exception on node <Attribute.connect l.331 at 0x225d8ac71c0> in file 'C:\leo.repo\leo-editor\leo\plugins\nodetags.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.nodetags
leo\plugins\nodetags.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\nodetags.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
.Exception on node <Attribute.connect l.207 at 0x12c6265ee00> in file 'C:\leo.repo\leo-editor\leo\plugins\nodewatch.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.nodewatch
leo\plugins\nodewatch.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\nodewatch.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
...........Exception on node <Attribute.connect l.94 at 0x1e87216d390> in file 'C:\leo.repo\leo-editor\leo\plugins\qt_commands.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.qt_commands
leo\plugins\qt_commands.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\qt_commands.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
..Exception on node <Attribute.connect l.689 at 0x1862ac6a8c0> in file 'C:\leo.repo\leo-editor\leo\plugins\qt_frame.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.qt_frame
leo\plugins\qt_frame.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\qt_frame.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
.Exception on node <Attribute.connect l.363 at 0x21d92948b50> in file 'C:\leo.repo\leo-editor\leo\plugins\qt_gui.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.qt_gui
leo\plugins\qt_gui.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\qt_gui.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
.Exception on node <Attribute.connect l.67 at 0x22eb67658a0> in file 'C:\leo.repo\leo-editor\leo\plugins\qt_idle_time.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.qt_idle_time
leo\plugins\qt_idle_time.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\qt_idle_time.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
....Exception on node <Attribute.connect l.500 at 0x1cb892eed40> in file 'C:\leo.repo\leo-editor\leo\plugins\qt_text.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.qt_text
leo\plugins\qt_text.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\qt_text.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
...Exception on node <Attribute.connect l.316 at 0x29da5907a90> in file 'C:\leo.repo\leo-editor\leo\plugins\quicksearch.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.quicksearch
leo\plugins\quicksearch.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\quicksearch.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
....Exception on node <Attribute.connect l.219 at 0x154151f3700> in file 'C:\leo.repo\leo-editor\leo\plugins\remove_duplicate_pictures.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.remove_duplicate_pictures
leo\plugins\remove_duplicate_pictures.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\remove_duplicate_pictures.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
..............Exception on node <Attribute.connect l.191 at 0x2b26fe09f00> in file 'C:\leo.repo\leo-editor\leo\plugins\stickynotes.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.stickynotes
leo\plugins\stickynotes.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\stickynotes.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
.Exception on node <Attribute.connect l.625 at 0x1e00a5927d0> in file 'C:\leo.repo\leo-editor\leo\plugins\stickynotes_plus.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.stickynotes_plus
leo\plugins\stickynotes_plus.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\stickynotes_plus.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
.....Exception on node <Attribute.connect l.30 at 0x229b8fe0fd0> in file 'C:\leo.repo\leo-editor\leo\plugins\threadutil.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.threadutil
leo\plugins\threadutil.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\threadutil.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
.......Exception on node <Attribute.connect l.1664 at 0x1de7e4d70d0> in file 'C:\leo.repo\leo-editor\leo\plugins\viewrendered.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.viewrendered
leo\plugins\viewrendered.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\viewrendered.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
.Exception on node <Attribute.connect l.2204 at 0x234ca9a2e30> in file 'C:\leo.repo\leo-editor\leo\plugins\viewrendered3.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.viewrendered3
leo\plugins\viewrendered3.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\viewrendered3.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
................Exception on node <Attribute.connect l.83 at 0x14e0d9417b0> in file 'C:\leo.repo\leo-editor\leo\plugins\xdb_pane.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1057, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
************* Module leo.plugins.xdb_pane
leo\plugins\xdb_pane.py:1:0: F0001: Fatal error while checking 'C:\leo.repo\leo-editor\leo\plugins\xdb_pane.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-07-07.txt'. (fatal)
.....254 files, time: 1039.29 sec.

Expected behavior

No pylint crashes :-) The pylint messages appear reasonable.

Pylint version

pylint 2.14.0-dev0
astroid 2.11.2
Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)]

OS / Environment

Leo 6.6.1-devel, ekr-unit-tests branch, build 77f47d62b3 2022-04-06 13:50:52 -0500 Python 3.10.4, PyQt version 6.2.4 Windows 10 AMD64 (build 10.0.22000) SP0

Additional dependencies

C:\leo.repo\leo-editor>python -m pip freeze

astroid==2.11.2 atomicwrites==1.4.0 attrs==21.4.0 beautifulsoup4==4.10.0 black==22.3.0 bleach==4.1.0 certifi==2021.10.8 charset-normalizer==2.0.12 click==8.1.0 colorama==0.4.4 coverage==6.3.2 cycler==0.11.0 defusedxml==0.7.1 dialite==0.5.3 dill==0.3.4 distlib==0.3.4 docutils==0.18.1 entrypoints==0.4 feedparser==6.0.8 filelock==3.6.0 flexx==0.8.3 fonttools==4.31.2 idna==3.3 ImageHash==4.2.1 iniconfig==1.1.1 isort==5.10.1 Jinja2==3.1.1 jsonschema==4.4.0 jupyter-client==7.2.1 jupyter-core==4.9.2 jupyterlab-pygments==0.1.2 kiwisolver==1.4.1 lazy-object-proxy==1.7.1 leo==6.6 lxml==4.8.0 Markdown==3.3.6 MarkupSafe==2.1.1 matplotlib==3.5.1 mccabe==0.7.0 mistune==0.8.4 mypy-extensions==0.4.3 nbclient==0.5.13 nbconvert==6.4.5 nbformat==5.2.0 nest-asyncio==1.5.5 numpy==1.22.3 packaging==21.3 pandocfilters==1.5.0 pathspec==0.9.0 Pillow==9.0.1 platformdirs==2.5.1 pluggy==1.0.0 pscript==0.7.7 py==1.11.0 pyenchant==3.2.2 Pygments==2.11.2 -e git+https://github.com/PyCQA/pylint.git@ba08c9d1ab8b624b4491a29bfc2f274dc00eeab8#egg=pylint pyparsing==3.0.7 PyQt5==5.15.6 PyQt5-Qt5==5.15.2 PyQt5-sip==12.9.1 PyQt6==6.2.3 PyQt6-Qt6==6.2.4 PyQt6-sip==13.2.1 PyQt6-WebEngine==6.2.1 PyQt6-WebEngine-Qt6==6.2.4 pyrsistent==0.18.1 pytest==7.1.1 pytest-cov==3.0.0 python-dateutil==2.8.2 PyWavelets==1.3.0 pywin32==303 PyYAML==6.0 pyzmq==22.3.0 requests==2.27.1 scipy==1.8.0 Send2Trash==1.8.0 sgmllib3k==1.0.0 six==1.16.0 soupsieve==2.3.1 testpath==0.6.0 toml==0.10.2 tomli==2.0.1 tornado==6.1 tox==3.24.5 traitlets==5.1.1 types-docutils==0.18.0 types-requests==2.27.15 types-urllib3==1.26.11 typing_extensions==4.1.1 urllib3==1.26.9 virtualenv==20.14.0 webencodings==0.5.1 webruntime==0.5.8 websockets==10.2 windows-curses==2.3.0 wrapt==1.14.0

Pierre-Sassoulas commented 2 years ago

Possibly a windows only issue, the example does not crash for me. What is the commit used in your local pylint ?

edreamleo commented 2 years ago

@Pierre-Sassoulas

ba08c9d1ab8b624b4491a29bfc2f274dc00eeab8

Author: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>  2022-04-06 14:43:11
Committer: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>  2022-04-06 16:19:42
Parent: e7be960c810e9333064d4ea09a5cda43d77c0ec7 (Add ``_option_dicts`` attribute to ``_ArgumentsManager``)
Branches: main, remotes/origin/main
Follows: v2.13.5
Precedes: 

    Move ``test_generate_config_disable_symbolic_names``
DanielNoord commented 2 years ago

@edreamleo Could I ask you to print out attr_nodes on L1055?

L1057 was changed in https://github.com/PyCQA/pylint/pull/5544. It might be possible that this caused a regression? But honestly I don't immediately see how attr_nodes = owner.getattr(node.attrname) can return a list of strings... Peculiar bug 😅

edreamleo commented 2 years ago

@DanielNoord What do you mean "on L1055"?

DanielNoord commented 2 years ago

@DanielNoord What do you mean "on L1055"?

Oh sorry, should have been clearer. Line 1055 in c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py. The crash occurs on line 1057 and it might help us to know what attr_nodes is on line 1055 just before the crash.

edreamleo commented 2 years ago

@DanielNoord Will do. Probably later today.

edreamleo commented 2 years ago

@DanielNoord

At line 1057 I replaced the unguarded access to attr_parent = attr_node.parent with:

try:
    attr_parent = attr_node.parent
except AttributeError:
    print('EKR', attr_node) ###
    raise

The extra output was: EKR self.

BTW, for reasons that I do not understand, adding just the print statement (outside the try/except) hung pylint.

edreamleo commented 2 years ago

@DanielNoord Sorry, wrong recipient the first time.

On second thought, the "hang" is likely a Leo artifact. A pipe created by subprocess.Popen probably blocked. It's an ongoing Leo issue :-)

DanielNoord commented 2 years ago

I'm going to ping @jacobtylerwalls as this is probably related to his PR #5544.

@edreamleo Do you have a short code snippet that always trigger this crash?

edreamleo commented 2 years ago

@DanielNoord No, but I should be able to create one. One of the failing files is fairly short.

edreamleo commented 2 years ago

@DanielNoord Here is a reduction of leo/core/leoPrinting.py that still crashes for me:

"""
Test file for pylint issue #6221: https://github.com/PyCQA/pylint/issues/6221

Adapted from leo/core/leoPrinting.py
"""
try:  # #1973
    from leo.core.leoQt import printsupport, QtGui
    from leo.core.leoQt import DialogCode
except Exception:
    printsupport = QtGui = None  # type:ignore
    DialogCode = None  # type:ignore

class PrintingController:
    """A class supporting the commands in Leo's File:Print menu."""

    document = None  # #6221: Suppress extraneous pylint complaint.
    c = None   # #6221: Suppress extraneous pylint complaint.

    def preview_body(self, event=None):
        """Preview the body of the selected node."""
        doc = self.document(self.c.p.b)
        self.preview_doc(doc)

    def preview_doc(self, doc):
        """Preview the document."""
        # pylint: disable=no-member
        dialog = printsupport.QPrintPreviewDialog()
        dialog.setSizeGripEnabled(True)
        dialog.paintRequested.connect(doc.print)   # <=== OOPS!
        dialog.exec_()
DanielNoord commented 2 years ago

@DanielNoord Here is a reduction of leo/core/leoPrinting.py that still crashes for me:

"""
Test file for pylint issue #6221: https://github.com/PyCQA/pylint/issues/6221

Adapted from leo/core/leoPrinting.py
"""
from leo.core import leoGlobals as g
#
# Qt imports. May fail from the bridge.
try:  # #1973
    from leo.core.leoQt import printsupport, QtGui
    from leo.core.leoQt import DialogCode
except Exception:
    printsupport = QtGui = None  # type:ignore
    DialogCode = None  # type:ignore
class PrintingController:
    """A class supporting the commands in Leo's File:Print menu."""

    document = None
    c = None

    def preview_body(self, event=None):
        """Preview the body of the selected node."""
        doc = self.document(self.c.p.b)
        self.preview_doc(doc)
    def preview_doc(self, doc):
        """Preview the document."""
        # pylint: disable=no-member
        dialog = printsupport.QPrintPreviewDialog()
        dialog.setSizeGripEnabled(True)
        dialog.paintRequested.connect(doc.print)
        dialog.exec_()

Hmm, I can't get that to crash on main on Mac. One thing I notice is that those imports are not used in the code. Are they necessary for pylint to crash?

jacobtylerwalls commented 2 years ago

Might need to spin up a fresh venv with the packages from the report. That can affect inference.

edreamleo commented 2 years ago

@DanielNoord Yes, the imports appear necessary. I admit, this particular snippet is very strange. If you like, I can try to find another snippet.

jacobtylerwalls commented 2 years ago

Let's just continue bisecting this one. Can you include the entire crash output? My guess is that chained assignment to printsupport in the except is one-half of what's needed, given where the disable no-member is located.

DanielNoord commented 2 years ago

Might need to spin up a fresh venv with the packages from the report. That can affect inference.

I did a fresh venv with pip install leo, but I might obviously be missing an important package.

edreamleo commented 2 years ago

@DanielNoord I may be able to simplify the example...

edreamleo commented 2 years ago

@DanielNoord On my system all the imports succeed, so the example can just start with the following:

from leo.core.leoQt import printsupport, QtGui
from leo.core.leoQt import DialogCode

This still gives a fatal error, as expected.

But: we should be able to simplify the example further by using PyQt6 imports defined in leoQt.py (via leoQt6.py):

from PyQt6 import QtWidgets
from PyQt6 import QtPrintSupport as printsupport
DialogCode = QtWidgets.QDialog.DialogCode

But now pylint doesn't crash, and instead complains:

c:\test\test_leoPrinting.py:34:14: E1102: self.document is not callable.

edreamleo commented 2 years ago

@DanielNoord Hmm. leoQt.py gets access to the symbols in leoQt6.py this way:

from leo.core.leoQt6 import *

So maybe this extra level of indirection is bothering pylint.

jacobtylerwalls commented 2 years ago

@edreamleo could you post the entire crash report? You can wrap it in a <details> tag so that it doesn't overwhelm the thread.

like this
edreamleo commented 2 years ago

@jacobtylerwalls Will do.

edreamleo commented 2 years ago

@jacobtylerwalls Here is the entire crash report, from pylint-crash-2022-04-08-05.txt:

First, please verify that the bug is not already filled: https://github.com/PyCQA/pylint/issues/ Then create a new crash issue: https://github.com/PyCQA/pylint/issues/new?assignees=&labels=crash%2Cneeds+triage&template=BUG-REPORT.yml Issue title: Crash ``'str' object has no attribute 'parent'`` (if possible, be more specific about what made pylint crash) Content: When parsing the following file: ```python """ Test file for pylint issue #6221: https://github.com/PyCQA/pylint/issues/6221 Adapted from leo/core/leoPrinting.py """ # Crashes from leo.core.leoQt import printsupport, QtGui from leo.core.leoQt import DialogCode # Does not crash # from leo.core.leoQt6 import printsupport, QtGui # from leo.core.leoQt6 import DialogCode # Does not crash # from PyQt6 import QtWidgets # from PyQt6 import QtPrintSupport as printsupport # DialogCode = QtWidgets.QDialog.DialogCode class PrintingController: """A class supporting the commands in Leo's File:Print menu.""" document = None # #6221: Suppress extraneous pylint complaint. c = None # #6221: Suppress extraneous pylint complaint. def preview_body(self, event=None): """Preview the body of the selected node.""" doc = self.document(self.c.p.b) self.preview_doc(doc) def preview_doc(self, doc): """Preview the document.""" # pylint: disable=no-member dialog = printsupport.QPrintPreviewDialog() dialog.setSizeGripEnabled(True) dialog.paintRequested.connect(doc.print) dialog.exec_() ``` pylint crashed with a ``AttributeError`` and with the following stacktrace: ``` Traceback (most recent call last): File "c:\leo.repo\ekr-pylint\pylint\lint\pylinter.py", line 1124, in _check_files self._check_file(get_ast, check_astroid_module, file) File "c:\leo.repo\ekr-pylint\pylint\lint\pylinter.py", line 1159, in _check_file check_astroid_module(ast_node) File "c:\leo.repo\ekr-pylint\pylint\lint\pylinter.py", line 1311, in check_astroid_module retval = self._check_astroid_module( File "c:\leo.repo\ekr-pylint\pylint\lint\pylinter.py", line 1358, in _check_astroid_module walker.walk(node) File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 76, in walk self.walk(child) File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 76, in walk self.walk(child) File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 76, in walk self.walk(child) [Previous line repeated 2 more times] File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk callback(astroid) File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1058, in visit_attribute attr_parent = attr_node.parent AttributeError: 'str' object has no attribute 'parent' ```
edreamleo commented 2 years ago

And here is the console output, with an extra trace inserted in typecheck.py:

C:\leo.repo\leo-editor>python -m pylint-leo -f c:\test\test_leoPrinting.py
************* Module Test.test_leoPrinting
c:\test\test_leoPrinting.py:34:14: E1102: self.document is not callable (not-callable)
EKR self  # <==== new trace.
Exception on node <Attribute.connect l.42 at 0x1b88e392050> in file 'c:\test\test_leoPrinting.py'
Traceback (most recent call last):
  File "c:\leo.repo\ekr-pylint\pylint\utils\ast_walker.py", line 73, in walk
    callback(astroid)
  File "c:\leo.repo\ekr-pylint\pylint\checkers\typecheck.py", line 1058, in visit_attribute
    attr_parent = attr_node.parent
AttributeError: 'str' object has no attribute 'parent'
c:\test\test_leoPrinting.py:1:0: F0001: Fatal error while checking 'c:\test\test_leoPrinting.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\Edward Ream\AppData\Local\pylint\pylint\Cache\pylint-crash-2022-04-08-05.txt'. (fatal)
.1 file, time:  0.72 sec.

C:\leo.repo\leo-editor>
jacobtylerwalls commented 2 years ago

Thanks, I can reproduce it now. I needed to:

Assigning myself with the intent of having a look soon at the root cause, but any help is welcome. Thanks for the report!

jacobtylerwalls commented 2 years ago

Bisected it to #5544 in 2.14 (glad we didn't rush it into 2.13!) I just need to restore an except for ast's built from living objects. Thanks for testing on main!

edreamleo commented 2 years ago

@jacobtylerwalls You're welcome. Glad to hear the fix was straightforward.

edreamleo commented 2 years ago

@jacobtylerwalls The code in ee94d81 works for me. Many thanks for the quick fix.

jacobtylerwalls commented 2 years ago

@edreamleo actually, may I ask you to test an alternative solution? This is the root cause and actually testable in a real way! https://github.com/PyCQA/astroid/pull/1505

edreamleo commented 2 years ago

@jacobtylerwalls Will do. Probably tomorrow.

edreamleo commented 2 years ago

Tests still fail for me, but I suspect that I have not installed the PR properly. Here is what I did:

Now python -m pylint-leo -v reports:

pylint 2.14.0-dev0
astroid 2.12.0-dev0
Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)]

What should I do now? Thanks.

edreamleo commented 2 years ago

Hmm. I suppose I should do gh pr checkout 1505, but I'm not sure what that means.

edreamleo commented 2 years ago

Ok, from https://github.com/cli/cli I did: git clone https://github.com/cli/cli

I'll get the gh command working and see if that helps :-)

Pierre-Sassoulas commented 2 years ago

I think you need to switch the branch to the qt-brain one from @jacobtylerwalls as the default one is main, so between

edreamleo commented 2 years ago

@Pierre-Sassoulas Thanks. I'll try that.

Also, I see that there is an msi installer for gh cli on Windows, which I've just installed. Now 'gh' works.

edreamleo commented 2 years ago

@Pierre-Sassoulas git switch qt-brain appears to have worked.

I'm still running tests (they take over 1000 sec), but there are no crashes in the files that crashed before, only new pylint warnings :-)

pip install . issued warnings, but apparently I can ignore them. Here is the full log:

c:\leo.repo\ekr-pylint-6221>python -m pip install . c:\leo.repo\ekr-pylint-6221>echo off Processing c:\leo.repo\ekr-pylint-6221 Preparing metadata (setup.py) ... done Requirement already satisfied: lazy_object_proxy>=1.4.0 in c:\users\edward ream\python\python310\lib\site-packages (from astroid==2.12.0.dev0) (1.7.1) Requirement already satisfied: wrapt<2,>=1.11 in c:\users\edward ream\python\python310\lib\site-packages (from astroid==2.12.0.dev0) (1.14.0) Requirement already satisfied: setuptools>=20.0 in c:\users\edward ream\python\python310\lib\site-packages (from astroid==2.12.0.dev0) (58.1.0) Using legacy 'setup.py install' for astroid, since package 'wheel' is not installed. Installing collected packages: astroid Attempting uninstall: astroid Found existing installation: astroid 2.12.0.dev0 Uninstalling astroid-2.12.0.dev0: Successfully uninstalled astroid-2.12.0.dev0 Running setup.py install for astroid ... done ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. leo 6.6 requires asttokens, which is not installed. leo 6.6 requires build>=0.6.0, which is not installed. leo 6.6 requires meta, which is not installed. leo 6.6 requires pyflakes, which is not installed. leo 6.6 requires PyQtWebEngine, which is not installed. leo 6.6 requires pyshortcuts>=1.7, which is not installed. leo 6.6 requires sphinx, which is not installed. Successfully installed astroid-2.12.0.dev0
edreamleo commented 2 years ago

@Pierre-Sassoulas All tests just completed: 282 files, time: 1198.07 sec.

So I have done all the testing that I can. Thanks again for the quick fix.

jacobtylerwalls commented 2 years ago

Reopening to make sure we release astroid and depend on it in pylint for 2.14.

jacobtylerwalls commented 2 years ago

Fixed in #6398