mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 14:34:31 +08:00
Change search strategy for adding parent paths:
1. skip dirs with __init__.py 2. Stop immediately when above self._path
This commit is contained in:
@@ -110,16 +110,15 @@ class Project(object):
|
|||||||
suffixed += discover_buildout_paths(inference_state, inference_state.script_path)
|
suffixed += discover_buildout_paths(inference_state, inference_state.script_path)
|
||||||
|
|
||||||
if add_parent_paths:
|
if add_parent_paths:
|
||||||
# Collect directories in upward search until we:
|
# Collect directories in upward search by:
|
||||||
# 1. Hit any directory without an __init__.py, AND
|
# 1. Skipping directories with __init__.py
|
||||||
# 2. Are above self._path.
|
# 2. Stopping immediately when above self._path
|
||||||
traversed = []
|
traversed = []
|
||||||
no_init = False
|
|
||||||
for parent_path in traverse_parents(inference_state.script_path):
|
for parent_path in traverse_parents(inference_state.script_path):
|
||||||
if not os.path.isfile(os.path.join(parent_path, "__init__.py")):
|
if not parent_path.startswith(self._path):
|
||||||
no_init = True
|
|
||||||
if no_init and not parent_path.startswith(self._path):
|
|
||||||
break
|
break
|
||||||
|
if os.path.isfile(os.path.join(parent_path, "__init__.py")):
|
||||||
|
continue
|
||||||
traversed.append(parent_path)
|
traversed.append(parent_path)
|
||||||
|
|
||||||
# AFAIK some libraries have imports like `foo.foo.bar`, which
|
# AFAIK some libraries have imports like `foo.foo.bar`, which
|
||||||
|
|||||||
Reference in New Issue
Block a user