edaniszewski / pylint-quotes

Pylint plugin for checking the consistency of string quotes
MIT License
42 stars 13 forks source link

Tool fails on file with only a comment #2

Closed BenjaminSchubert closed 7 years ago

BenjaminSchubert commented 7 years ago

When running pylint-quotes on a project that has a file like

"""This is my toplevel module."""

It will fail at https://github.com/edaniszewski/pylint-quotes/blob/master/pylint_quotes/checker.py#L149

with a traceback like

  File "/home/tellendil/.virtualenvs/entrepy/lib64/python3.6/site-packages/pylint/lint.py", line 726, in check
    self._do_check(files_or_modules)
  File "/home/tellendil/.virtualenvs/entrepy/lib64/python3.6/site-packages/pylint/lint.py", line 855, in _do_check
    self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
  File "/home/tellendil/.virtualenvs/entrepy/lib64/python3.6/site-packages/pylint/lint.py", line 934, in check_astroid_module
    walker.walk(ast_node)
  File "/home/tellendil/.virtualenvs/entrepy/lib64/python3.6/site-packages/pylint/utils.py", line 970, in walk
    cb(astroid)
  File "/home/tellendil/.virtualenvs/entrepy/lib64/python3.6/site-packages/pylint_quotes/checker.py", line 102, in visit_module
    self._process_for_docstring(node, 'module')
  File "/home/tellendil/.virtualenvs/entrepy/lib64/python3.6/site-packages/pylint_quotes/checker.py", line 149, in _process_for_docstring
    for i in range(0, node.body[0].lineno):
IndexError: list index out of range
edaniszewski commented 7 years ago

thanks for opening the issue (:

added some changes via the referenced PR that should fix this. haven't yet released a new version which this change. i'm in the process of putting together a test suite that will include this case -- once thats in, i'll release.