mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-16 02:27:06 +08:00
fix Completion.parent() issues with builtins
This commit is contained in:
@@ -340,6 +340,9 @@ class BaseDefinition(object):
|
||||
return [_Param(self._evaluator, p) for p in params]
|
||||
|
||||
def parent(self):
|
||||
if isinstance(self._definition, compiled.CompiledObject):
|
||||
non_flow = self._definition.parent
|
||||
else:
|
||||
scope = self._definition.get_parent_until(pr.IsScope, include_current=False)
|
||||
non_flow = scope.get_parent_until(pr.Flow, reverse=True)
|
||||
return Definition(self._evaluator, non_flow)
|
||||
|
||||
@@ -54,8 +54,7 @@ def test_line_number_errors():
|
||||
|
||||
def _check_number(source, result='float'):
|
||||
completions = api.Script(source).completions()
|
||||
#assert completions[0].parent().name == result
|
||||
assert completions[0]._definition.parent.name == result
|
||||
assert completions[0].parent().name == result
|
||||
|
||||
|
||||
def test_completion_on_number_literals():
|
||||
|
||||
Reference in New Issue
Block a user