Skip to content

Fix error when resolving completion items for Rope #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions pylsp/plugins/rope_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ def pylsp_settings():


def _resolve_completion(completion, data):
# pylint: disable=broad-except
try:
doc = data.get_doc()
except AttributeError:
except Exception as e:
log.debug("Failed to resolve Rope completion: %s", e)
doc = ""
completion['detail'] = '{0} {1}'.format(data.scope or "", data.name)
completion['documentation'] = doc
Expand Down Expand Up @@ -83,8 +85,11 @@ def pylsp_completions(config, workspace, document, position):
@hookimpl
def pylsp_completion_item_resolve(completion_item, document):
"""Resolve formatted completion for given non-resolved completion"""
completion, data = document.shared_data['LAST_ROPE_COMPLETIONS'].get(completion_item['label'])
return _resolve_completion(completion, data)
shared_data = document.shared_data['LAST_ROPE_COMPLETIONS'].get(completion_item['label'])
if shared_data:
completion, data = shared_data
return _resolve_completion(completion, data)
return completion_item


def _sort_text(definition):
Expand Down