mirror of
https://github.com/davidhalter/jedi.git
synced 2026-04-28 10:35:31 +08:00
Fix star import completions, fixes #2087
This commit is contained in:
@@ -61,6 +61,7 @@ class MixedModuleContext(ModuleContext):
|
||||
)
|
||||
|
||||
def get_filters(self, until_position=None, origin_scope=None):
|
||||
|
||||
yield MergedFilter(
|
||||
MixedParserTreeFilter(
|
||||
parent_context=self,
|
||||
@@ -72,3 +73,10 @@ class MixedModuleContext(ModuleContext):
|
||||
|
||||
for mixed_object in self.mixed_values:
|
||||
yield from mixed_object.get_filters(until_position, origin_scope)
|
||||
|
||||
# Now that we have merged the filter for this mixed context we have to
|
||||
# remove the first entry (which is the module itself), but we want to
|
||||
# add the other filters like the star imports.
|
||||
filters = self._value.get_filters(origin_scope)
|
||||
next(filters, None)
|
||||
yield from filters
|
||||
|
||||
@@ -858,3 +858,12 @@ def test_custom__getitem__(class_is_findable, allow_unsafe_getattr):
|
||||
else:
|
||||
expected = ['upper']
|
||||
_assert_interpreter_complete('c["a"].up', namespace, expected)
|
||||
|
||||
|
||||
def test_star_import_completions():
|
||||
# From #2087
|
||||
completions = jedi.Interpreter("from json import *\ndum", []).complete(2, 3)
|
||||
names = [c.name for c in completions]
|
||||
|
||||
assert 'dump' in names
|
||||
assert 'dumps' in names
|
||||
|
||||
Reference in New Issue
Block a user