diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-01-09 16:57:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-09 16:57:55 +0100 |
commit | 5c565b728510b4e8360de3c5b1434c51ccb96b1f (patch) | |
tree | 48db87af756d9bc4d28ca084842f3897e7e672a8 /astroid/modutils.py | |
parent | d2a5b3c7b1e203fec3c7ca73c30eb1785d3d4d0a (diff) | |
download | astroid-git-5c565b728510b4e8360de3c5b1434c51ccb96b1f.tar.gz |
Fix finding packages without an ``__init__.py`` (#1333)
Diffstat (limited to 'astroid/modutils.py')
-rw-r--r-- | astroid/modutils.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/astroid/modutils.py b/astroid/modutils.py index 6d698469..b20a1840 100644 --- a/astroid/modutils.py +++ b/astroid/modutils.py @@ -297,6 +297,9 @@ def _get_relative_base_path(filename, path_to_check): if os.path.normcase(real_filename).startswith(path_to_check): importable_path = real_filename + # if "var" in path_to_check: + # breakpoint() + if importable_path: base_path = os.path.splitext(importable_path)[0] relative_base_path = base_path[len(path_to_check) :] @@ -307,8 +310,11 @@ def _get_relative_base_path(filename, path_to_check): def modpath_from_file_with_callback(filename, path=None, is_package_cb=None): filename = os.path.expanduser(_path_from_filename(filename)) + paths_to_check = sys.path.copy() + if path: + paths_to_check += path for pathname in itertools.chain( - path or [], map(_cache_normalize_path, sys.path), sys.path + paths_to_check, map(_cache_normalize_path, paths_to_check) ): if not pathname: continue |