Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if string_names is None before returning string_names #1708

Merged
merged 5 commits into from Dec 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.txt
Expand Up @@ -60,6 +60,7 @@ Code Contributors
- Max Mäusezahl (@mmaeusezahl) <maxmaeusezahl@googlemail.com>
- Vladislav Serebrennikov (@endilll)
- Andrii Kolomoiets (@muffinmad)
- Leo Ryu (@Leo-Ryu)

And a few more "anonymous" contributors.

Expand Down
3 changes: 3 additions & 0 deletions jedi/inference/value/module.py
Expand Up @@ -179,6 +179,9 @@ def is_package(self):
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]
Expand Down
3 changes: 3 additions & 0 deletions test/test_inference/test_imports.py
Expand Up @@ -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')
Expand Down