forked from VimPlug/jedi
Merge pull request #1805 from kirat-singh/support_nested_namespace_packages
fix(import): support for nested namespace packages
This commit is contained in:
@@ -422,20 +422,13 @@ def import_module(inference_state, import_names, parent_module_value, sys_path):
|
|||||||
# The module might not be a package.
|
# The module might not be a package.
|
||||||
return NO_VALUES
|
return NO_VALUES
|
||||||
|
|
||||||
for path in paths:
|
file_io_or_ns, is_pkg = inference_state.compiled_subprocess.get_module_info(
|
||||||
# At the moment we are only using one path. So this is
|
string=import_names[-1],
|
||||||
# not important to be correct.
|
path=paths,
|
||||||
if not isinstance(path, list):
|
full_name=module_name,
|
||||||
path = [path]
|
is_global_search=False,
|
||||||
file_io_or_ns, is_pkg = inference_state.compiled_subprocess.get_module_info(
|
)
|
||||||
string=import_names[-1],
|
if is_pkg is None:
|
||||||
path=path,
|
|
||||||
full_name=module_name,
|
|
||||||
is_global_search=False,
|
|
||||||
)
|
|
||||||
if is_pkg is not None:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
return NO_VALUES
|
return NO_VALUES
|
||||||
|
|
||||||
if isinstance(file_io_or_ns, ImplicitNSInfo):
|
if isinstance(file_io_or_ns, ImplicitNSInfo):
|
||||||
|
|||||||
1
test/completion/namespace1/pkg1/pkg2/mod1.py
Normal file
1
test/completion/namespace1/pkg1/pkg2/mod1.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
mod1_name = 'mod1'
|
||||||
1
test/completion/namespace2/pkg1/pkg2/mod2.py
Normal file
1
test/completion/namespace2/pkg1/pkg2/mod2.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
mod2_name = 'mod2'
|
||||||
18
test/completion/ns_path.py
Normal file
18
test/completion/ns_path.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
from os.path import dirname
|
||||||
|
|
||||||
|
sys.path.insert(0, os.path.join(dirname(__file__), 'namespace2'))
|
||||||
|
sys.path.insert(0, os.path.join(dirname(__file__), 'namespace1'))
|
||||||
|
|
||||||
|
#? ['mod1']
|
||||||
|
import pkg1.pkg2.mod1
|
||||||
|
|
||||||
|
#? ['mod2']
|
||||||
|
import pkg1.pkg2.mod2
|
||||||
|
|
||||||
|
#? ['mod1_name']
|
||||||
|
pkg1.pkg2.mod1.mod1_name
|
||||||
|
|
||||||
|
#? ['mod2_name']
|
||||||
|
pkg1.pkg2.mod2.mod2_name
|
||||||
Reference in New Issue
Block a user