mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
If the stub module is not a package but the actual module is, it should not fail the import
This commit is contained in:
@@ -172,7 +172,7 @@ class ModuleContext(ModuleMixin, TreeContext):
|
|||||||
|
|
||||||
return os.path.abspath(self._path)
|
return os.path.abspath(self._path)
|
||||||
|
|
||||||
def _is_package(self):
|
def is_package(self):
|
||||||
return self._get_init_directory() is not None
|
return self._get_init_directory() is not None
|
||||||
|
|
||||||
def py__package__(self):
|
def py__package__(self):
|
||||||
@@ -218,7 +218,7 @@ class ModuleContext(ModuleMixin, TreeContext):
|
|||||||
is a list of paths (strings).
|
is a list of paths (strings).
|
||||||
Raises an AttributeError if the module is not a package.
|
Raises an AttributeError if the module is not a package.
|
||||||
"""
|
"""
|
||||||
if self._is_package():
|
if self.is_package():
|
||||||
return self._py__path__
|
return self._py__path__
|
||||||
else:
|
else:
|
||||||
raise AttributeError('Only packages have __path__ attributes.')
|
raise AttributeError('Only packages have __path__ attributes.')
|
||||||
|
|||||||
@@ -142,6 +142,10 @@ class TypeshedPlugin(BasePlugin):
|
|||||||
if len(import_names) == 1:
|
if len(import_names) == 1:
|
||||||
map_ = self._cache_stub_file_map(evaluator.grammar.version_info)
|
map_ = self._cache_stub_file_map(evaluator.grammar.version_info)
|
||||||
elif isinstance(parent_module_context, StubModuleContext):
|
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__()
|
path = parent_module_context.stub_context.py__path__()
|
||||||
map_ = _merge_create_stub_map(path)
|
map_ = _merge_create_stub_map(path)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user