summaryrefslogtreecommitdiff
path: root/pylint/utils/utils.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2020-03-11 15:26:22 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2020-03-12 11:02:35 +0100
commit709e74caca2b2b99863d04328cee94245fb04d8d (patch)
tree4a1ebbba81218ea31b4ea988a5d01426937c6069 /pylint/utils/utils.py
parenta96f60eeec49110748d9180724d74a05dd74f136 (diff)
downloadpylint-git-709e74caca2b2b99863d04328cee94245fb04d8d.tar.gz
Pass an additional search path to modutils.modpath_from_file and friends
Diffstat (limited to 'pylint/utils/utils.py')
-rw-r--r--pylint/utils/utils.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/pylint/utils/utils.py b/pylint/utils/utils.py
index dec15f29a..4ec73b9c2 100644
--- a/pylint/utils/utils.py
+++ b/pylint/utils/utils.py
@@ -135,15 +135,22 @@ def expand_modules(files_or_modules, black_list, black_list_re):
"""
result = []
errors = []
+ path = sys.path.copy()
+
for something in files_or_modules:
if os.path.basename(something) in black_list:
continue
if _basename_in_blacklist_re(os.path.basename(something), black_list_re):
continue
+
+ module_path = get_python_path(something)
+ additional_search_path = [module_path] + path
if os.path.exists(something):
# this is a file or a directory
try:
- modname = ".".join(modutils.modpath_from_file(something))
+ modname = ".".join(
+ modutils.modpath_from_file(something, path=additional_search_path)
+ )
except ImportError:
modname = os.path.splitext(os.path.basename(something))[0]
if os.path.isdir(something):
@@ -154,7 +161,9 @@ def expand_modules(files_or_modules, black_list, black_list_re):
# suppose it's a module or package
modname = something
try:
- filepath = modutils.file_from_modpath(modname.split("."))
+ filepath = modutils.file_from_modpath(
+ modname.split("."), path=additional_search_path
+ )
if filepath is None:
continue
except (ImportError, SyntaxError) as ex:
@@ -167,7 +176,9 @@ def expand_modules(files_or_modules, black_list, black_list_re):
modparts = (modname or something).split(".")
try:
- spec = modutils.file_info_from_modpath(modparts, path=sys.path)
+ spec = modutils.file_info_from_modpath(
+ modparts, path=additional_search_path
+ )
except ImportError:
# Might not be acceptable, don't crash.
is_namespace = False