diff --git a/jedi/evaluate/finder.py b/jedi/evaluate/finder.py index a7a57cc8..4db5bbaf 100644 --- a/jedi/evaluate/finder.py +++ b/jedi/evaluate/finder.py @@ -29,6 +29,7 @@ from jedi.evaluate.filters import get_global_filters from jedi.evaluate.names import TreeNameDefinition from jedi.evaluate.base_context import ContextSet, NO_CONTEXTS from jedi.parser_utils import is_scope, get_parent_scope +from jedi.evaluate.gradual.conversion import stub_to_actual_context_set class NameFinder(object): @@ -116,7 +117,17 @@ class NameFinder(object): return get_global_filters(self._evaluator, self._context, position, origin_scope) else: - return self._context.get_filters(search_global, self._position, origin_scope=origin_scope) + return self._get_context_filters(origin_scope) + + def _get_context_filters(self, origin_scope): + for f in self._context.get_filters(False, self._position, origin_scope=origin_scope): + yield f + # This covers the case where a stub files are incomplete. + if self._context.is_stub(): + contexts = stub_to_actual_context_set(self._context, ignore_compiled=True) + for c in contexts: + for f in c.get_filters(): + yield f def filter_name(self, filters): """ diff --git a/test/completion/stubs.py b/test/completion/stubs.py index 6dcba6f9..2d0444cf 100644 --- a/test/completion/stubs.py +++ b/test/completion/stubs.py @@ -8,7 +8,7 @@ from stub_folder import with_stub, stub_only, with_stub_folder, stub_only_folder stub_only.in_stub_only #? str() with_stub.in_with_stub_both -#? +#? int() with_stub.in_with_stub_python #? float() with_stub.in_with_stub_stub @@ -22,7 +22,7 @@ with_stub.in_with_stub_stub stub_only_folder.in_stub_only_folder #? str() with_stub_folder.in_with_stub_both_folder -#? +#? int() with_stub_folder.in_with_stub_python_folder #? float() with_stub_folder.in_with_stub_stub_folder @@ -38,7 +38,7 @@ from stub_folder.with_stub_folder import nested_stub_only, nested_with_stub, \ nested_stub_only.in_stub_only #? float() nested_with_stub.in_both -#? +#? str() nested_with_stub.in_python #? int() nested_with_stub.in_stub @@ -56,7 +56,7 @@ from stub_folder.stub_only_folder import nested_stub_only, nested_with_stub, \ nested_stub_only.in_stub_only #? float() nested_with_stub.in_both -#? +#? str() nested_with_stub.in_python #? int() nested_with_stub.in_stub diff --git a/test/test_evaluate/test_gradual/test_stub_loading.py b/test/test_evaluate/test_gradual/test_stub_loading.py index c3d4fc90..40dcffa8 100644 --- a/test/test_evaluate/test_gradual/test_stub_loading.py +++ b/test/test_evaluate/test_gradual/test_stub_loading.py @@ -16,7 +16,7 @@ def ScriptInStubFolder(Script): ('code', 'expected'), [ ('from no_python import foo', ['int']), ('from with_python import stub_only', ['str']), - ('from with_python import python_only', []), + ('from with_python import python_only', ['int']), ('from with_python import both', ['int']), ('from with_python import something_random', []), ('from with_python.module import in_sub_module', ['int']),