mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Fix an issue where compiled object api types raised an error.
This commit is contained in:
@@ -272,7 +272,7 @@ class CompiledName(AbstractNameDefinition):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def api_type(self):
|
def api_type(self):
|
||||||
return self.infer()[0].api_type
|
return next(iter(self.infer())).api_type
|
||||||
|
|
||||||
@underscore_memoization
|
@underscore_memoization
|
||||||
def infer(self):
|
def infer(self):
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ class DiffParser(object):
|
|||||||
assert operation == 'delete'
|
assert operation == 'delete'
|
||||||
|
|
||||||
# Cleanup (setting endmarker, used_names)
|
# Cleanup (setting endmarker, used_names)
|
||||||
self._post_parse()
|
self._cleanup()
|
||||||
if self._added_newline:
|
if self._added_newline:
|
||||||
self._parser.module = self._parser._parsed = self._new_module
|
self._parser.module = self._parser._parsed = self._new_module
|
||||||
self._parser.remove_last_newline()
|
self._parser.remove_last_newline()
|
||||||
@@ -414,11 +414,12 @@ class DiffParser(object):
|
|||||||
def _get_children_nodes(self, node):
|
def _get_children_nodes(self, node):
|
||||||
nodes = node.children
|
nodes = node.children
|
||||||
first_element = nodes[0]
|
first_element = nodes[0]
|
||||||
if first_element.type == 'error_leaf' and \
|
# TODO this looks very strange...
|
||||||
first_element.original_type == 'indent':
|
#if first_element.type == 'error_leaf' and \
|
||||||
assert nodes[-1].type == 'dedent'
|
#first_element.original_type == 'indent':
|
||||||
# This means that the start and end leaf
|
#assert nodes[-1].type == 'dedent'
|
||||||
nodes = nodes[1:-2] + [nodes[-1]]
|
## This means that the start and end leaf
|
||||||
|
#nodes = nodes[1:-1] + [nodes[-1]]
|
||||||
|
|
||||||
return nodes
|
return nodes
|
||||||
|
|
||||||
@@ -440,7 +441,7 @@ class DiffParser(object):
|
|||||||
)
|
)
|
||||||
return self._active_parser.parse(tokenizer=tokenizer)
|
return self._active_parser.parse(tokenizer=tokenizer)
|
||||||
|
|
||||||
def _post_parse(self):
|
def _cleanup(self):
|
||||||
# Add the used names from the old parser to the new one.
|
# Add the used names from the old parser to the new one.
|
||||||
copied_line_numbers = set()
|
copied_line_numbers = set()
|
||||||
for l1, l2 in self._copied_ranges:
|
for l1, l2 in self._copied_ranges:
|
||||||
|
|||||||
@@ -238,9 +238,13 @@ class TestParent(TestCase):
|
|||||||
|
|
||||||
|
|
||||||
def test_type():
|
def test_type():
|
||||||
"""
|
for c in Script('a = [str()]; a[0].').completions():
|
||||||
Github issue #397, type should never raise an error.
|
if c.name == '__class__':
|
||||||
"""
|
assert c.type == 'class'
|
||||||
|
else:
|
||||||
|
assert c.type in ('function', 'instance')
|
||||||
|
|
||||||
|
# Github issue #397, type should never raise an error.
|
||||||
for c in Script('import os; os.path.').completions():
|
for c in Script('import os; os.path.').completions():
|
||||||
assert c.type
|
assert c.type
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user