Skip to content

IndexError on empty test file

If a python test file is empty, an IndexError is triggered during flake8 plugin checks.

File "/home/mshriver/repos/ansible/<redacted>/.venv/lib64/python3.8/site-packages/flake8/checker.py", line 497, in run_ast_checks
    runner = checker.run()
  File "/home/mshriver/repos/redhatqe/polarion_docstrings/polarion_docstrings/flake8_plugin.py", line 57, in run
    return checks.get_errors()
  File "/home/mshriver/repos/redhatqe/polarion_docstrings/polarion_docstrings/checker.py", line 364, in get_errors
    return self.run_checks()
  File "/home/mshriver/repos/redhatqe/polarion_docstrings/polarion_docstrings/checker.py", line 331, in run_checks
    docstrings_in_file = parser.get_docstrings_in_file(self.filename, tree=self.tree)
  File "/home/mshriver/repos/redhatqe/polarion_docstrings/polarion_docstrings/parser.py", line 466, in get_docstrings_in_file
    return FileParser(filename, tree=tree, tests_only=tests_only).get_docstrings()
  File "/home/mshriver/repos/redhatqe/polarion_docstrings/polarion_docstrings/parser.py", line 448, in get_docstrings
    return self.process_ast_body(self.tree.body, is_top=True)
  File "/home/mshriver/repos/redhatqe/polarion_docstrings/polarion_docstrings/parser.py", line 422, in process_ast_body
    docstring = self.process_node(body[0], None, LEVELS.file)
IndexError: list index out of range
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information