diff --git a/jedi/evaluate/context/module.py b/jedi/evaluate/context/module.py index 5c46ea6e..929cb520 100644 --- a/jedi/evaluate/context/module.py +++ b/jedi/evaluate/context/module.py @@ -172,7 +172,7 @@ class ModuleContext(ModuleMixin, TreeContext): return os.path.abspath(self._path) - def _is_package(self): + def is_package(self): return self._get_init_directory() is not None def py__package__(self): @@ -218,7 +218,7 @@ class ModuleContext(ModuleMixin, TreeContext): is a list of paths (strings). Raises an AttributeError if the module is not a package. """ - if self._is_package(): + if self.is_package(): return self._py__path__ else: raise AttributeError('Only packages have __path__ attributes.') diff --git a/jedi/plugins/typeshed.py b/jedi/plugins/typeshed.py index 5f7051d0..2f3bbeaa 100644 --- a/jedi/plugins/typeshed.py +++ b/jedi/plugins/typeshed.py @@ -142,6 +142,10 @@ class TypeshedPlugin(BasePlugin): if len(import_names) == 1: map_ = self._cache_stub_file_map(evaluator.grammar.version_info) elif isinstance(parent_module_context, StubModuleContext): + if not parent_module_context.stub_context.is_package(): + # Only if it's a package (= a folder) something can be + # imported. + return context_set path = parent_module_context.stub_context.py__path__() map_ = _merge_create_stub_map(path)