Skip to content

Autoimport keep throwing exception when delete a line #307

Closed

Description

@douo
--- Send (notification): textDocument/didChange

--- Send (58706): textDocument/completion
2022-11-28 22:45:51,446 CST - WARNING - pylsp.config.config - Failed to load hook pylsp_completions: 'NoneType' object has no attribute 'value'
Traceback (most recent call last):
  File "▒▒▒▒▒▒▒▒/venv/lib/python3.10/site-packages/pylsp/config/config.py", line 33, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "▒▒▒▒▒▒▒▒/venv/lib/python3.10/site-packages/pluggy/_manager.py", line 327, in traced_hookexec
    return outcome.get_result()
  File "▒▒▒▒▒▒▒▒/venv/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "▒▒▒▒▒▒▒▒/venv/lib/python3.10/site-packages/pluggy/_result.py", line 33, in from_call
    result = func()
  File "▒▒▒▒▒▒▒▒/venv/lib/python3.10/site-packages/pluggy/_manager.py", line 324, in <lambda>
    lambda: oldcall(hook_name, hook_impls, kwargs, firstresult)
  File "▒▒▒▒▒▒▒▒/venv/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
  File "▒▒▒▒▒▒▒▒/venv/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "▒▒▒▒▒▒▒▒/venv/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "▒▒▒▒▒▒▒▒/venv/lib/python3.10/site-packages/pylsp/plugins/rope_autoimport.py", line 159, in pylsp_completions
    word = word_node.value
AttributeError: 'NoneType' object has no attribute 'value'

After I digging in code, I found the var line is alway a empty string when I delete a line

Activity

  1. ccordoba12 commented on Nov 28, 2022

    @ccordoba12
    Member

    Hey @douo, thanks for reporting. It seems that we need to add a validation to avoid this bug. Is it ok for you to submit a pull request to do that?

  2. added this to the v1.7.0 milestone on Nov 28, 2022
  3. ccordoba12 commented on Nov 28, 2022

    @ccordoba12
    Member

    Also, pinging @bagel897 about this, just in case.

  4. added a commit that references this issue on Nov 29, 2022
    78ea840
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions