From 8d48e7453a0c4b8521678d473fb7dd099212c47e Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Tue, 1 May 2018 23:15:54 +0200 Subject: [PATCH] When searching submodules, use all of __path__, fixes #1105 --- jedi/evaluate/context/module.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/jedi/evaluate/context/module.py b/jedi/evaluate/context/module.py index 8d4da11b..03fb0e55 100644 --- a/jedi/evaluate/context/module.py +++ b/jedi/evaluate/context/module.py @@ -186,13 +186,17 @@ class ModuleContext(TreeContext): Lists modules in the directory of this module (if this module is a package). """ - path = self._path names = {} - if path is not None and path.endswith(os.path.sep + '__init__.py'): - mods = iter_modules([os.path.dirname(path)]) - for module_loader, name, is_pkg in mods: - # It's obviously a relative import to the current module. - names[name] = SubModuleName(self, name) + try: + method = self.py__path__ + except AttributeError: + pass + else: + for path in method(): + mods = iter_modules([path]) + for module_loader, name, is_pkg in mods: + # It's obviously a relative import to the current module. + names[name] = SubModuleName(self, name) # TODO add something like this in the future, its cleaner than the # import hacks.