diff --git a/jedi/api/project.py b/jedi/api/project.py index 6ce05270..6c75cd79 100644 --- a/jedi/api/project.py +++ b/jedi/api/project.py @@ -110,16 +110,15 @@ class Project(object): suffixed += discover_buildout_paths(inference_state, inference_state.script_path) if add_parent_paths: - # Collect directories in upward search until we: - # 1. Hit any directory without an __init__.py, AND - # 2. Are above self._path. + # Collect directories in upward search by: + # 1. Skipping directories with __init__.py + # 2. Stopping immediately when above self._path traversed = [] - no_init = False for parent_path in traverse_parents(inference_state.script_path): - if not os.path.isfile(os.path.join(parent_path, "__init__.py")): - no_init = True - if no_init and not parent_path.startswith(self._path): + if not parent_path.startswith(self._path): break + if os.path.isfile(os.path.join(parent_path, "__init__.py")): + continue traversed.append(parent_path) # AFAIK some libraries have imports like `foo.foo.bar`, which