Skip to content

Commit f19b3b9

Browse files
Fix error when resolving completion items for Rope (#125)
Co-authored-by: Michał Krassowski <[email protected]>
1 parent 3096e6c commit f19b3b9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pylsp/plugins/rope_completion.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ def pylsp_settings():
1717

1818

1919
def _resolve_completion(completion, data):
20+
# pylint: disable=broad-except
2021
try:
2122
doc = data.get_doc()
22-
except AttributeError:
23+
except Exception as e:
24+
log.debug("Failed to resolve Rope completion: %s", e)
2325
doc = ""
2426
completion['detail'] = '{0} {1}'.format(data.scope or "", data.name)
2527
completion['documentation'] = doc
@@ -83,8 +85,11 @@ def pylsp_completions(config, workspace, document, position):
8385
@hookimpl
8486
def pylsp_completion_item_resolve(completion_item, document):
8587
"""Resolve formatted completion for given non-resolved completion"""
86-
completion, data = document.shared_data['LAST_ROPE_COMPLETIONS'].get(completion_item['label'])
87-
return _resolve_completion(completion, data)
88+
shared_data = document.shared_data['LAST_ROPE_COMPLETIONS'].get(completion_item['label'])
89+
if shared_data:
90+
completion, data = shared_data
91+
return _resolve_completion(completion, data)
92+
return completion_item
8893

8994

9095
def _sort_text(definition):

0 commit comments

Comments
 (0)