Skip to content

IndexError: list index out of range on empty document #206

@SamVerschueren

Description

@SamVerschueren

This is the error I get when I open a document with no content.

Python Server: Exception in thread Thread-9:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in__bootstrap_inner
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 1082, in run
    self.function(*self.args, **self.kwargs)
  File "/Users/sam/Library/Python/2.7/lib/python/site-packages/pyls/python_ls.py", line 100, in lint
    self.workspace.publish_diagnostics(doc_uri, flatten(self._hook('pyls_lint', doc_uri)))
  File "/Users/sam/Library/Python/2.7/lib/python/site-packages/pyls/python_ls.py", line 28, in _hook
    return self._hook_caller(hook_name)(config=self.config, workspace=self.workspace, document=doc, **kwargs)
  File "/Users/sam/Library/Python/2.7/lib/python/site-packages/pluggy/__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/Users/sam/Library/Python/2.7/lib/python/site-packages/pluggy/__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/sam/Library/Python/2.7/lib/python/site-packages/pluggy/__init__.py", line 182, in __call__
    return outcome.get_result()
  File "/Users/sam/Library/Python/2.7/lib/python/site-packages/pluggy/callers.py", line 77, in get_result
    _reraise(*ex)  # noqa
  File "/Users/sam/Library/Python/2.7/lib/python/site-packages/pluggy/callers.py", line 48, in from_call
    result = func()
  File "/Users/sam/Library/Python/2.7/lib/python/site-packages/pluggy/__init__.py", line 180, in <lambda>
    outcome = _Result.from_call(lambda: self.oldcall(hook, hook_impls, kwargs))
  File "/Users/sam/Library/Python/2.7/lib/python/site-packages/pluggy/__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "/Users/sam/Library/Python/2.7/lib/python/site-packages/pluggy/callers.py", line 201, in _multicall
    return outcome.get_result()
  File "/Users/sam/Library/Python/2.7/lib/python/site-packages/pluggy/callers.py", line 77, in get_result
    _reraise(*ex)  # noqa
  File "/Users/sam/Library/Python/2.7/lib/python/site-packages/pluggy/callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "/Users/sam/Library/Python/2.7/lib/python/site-packages/pyls/plugins/pydocstyle_lint.py", line 37, in pyls_lint
    line = document.lines[lineno]
IndexError: list index out of range

It happens here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions