diff --git a/AUTHORS.txt b/AUTHORS.txt index 6e881b7e..6ffe9dfd 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -60,6 +60,7 @@ Code Contributors - Max Mäusezahl (@mmaeusezahl) - Vladislav Serebrennikov (@endilll) - Andrii Kolomoiets (@muffinmad) +- Leo Ryu (@Leo-Ryu) And a few more "anonymous" contributors. diff --git a/jedi/inference/value/module.py b/jedi/inference/value/module.py index a5073b0e..f076d72a 100644 --- a/jedi/inference/value/module.py +++ b/jedi/inference/value/module.py @@ -179,6 +179,9 @@ class ModuleValue(ModuleMixin, TreeValue): return self._is_package def py__package__(self): + if self.string_names is None: + return [] + if self._is_package: return self.string_names return self.string_names[:-1] diff --git a/test/test_inference/test_imports.py b/test/test_inference/test_imports.py index 8e49244f..07ced324 100644 --- a/test/test_inference/test_imports.py +++ b/test/test_inference/test_imports.py @@ -96,6 +96,9 @@ def test_correct_zip_package_behavior(Script, inference_state, environment, code if path is not None: assert value.py__path__() == [str(pkg_zip_path.joinpath(path))] + value.string_names = None + assert value.py__package__() == [] + def test_find_module_not_package_zipped(Script, inference_state, environment): path = get_example_dir('zipped_imports', 'not_pkg.zip')