summaryrefslogtreecommitdiff
path: root/astroid/modutils.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2020-03-11 15:05:04 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2020-03-11 16:45:36 +0100
commitae09dfb7935737f2b393efe64ef76ce12f823446 (patch)
tree0d3cdf0c8c20c9e15bd8cf87e26cdae28c6bc8d9 /astroid/modutils.py
parent3a075c0205a717bbd68562da5017992c430549d3 (diff)
downloadastroid-git-ae09dfb7935737f2b393efe64ef76ce12f823446.tar.gz
Kill `extrapath` from various `modutils` functions as it was not used
Diffstat (limited to 'astroid/modutils.py')
-rw-r--r--astroid/modutils.py33
1 files changed, 8 insertions, 25 deletions
diff --git a/astroid/modutils.py b/astroid/modutils.py
index 0c009b13..9e37b995 100644
--- a/astroid/modutils.py
+++ b/astroid/modutils.py
@@ -254,7 +254,7 @@ def load_module_from_modpath(parts, path=None, use_sys=1):
return module
-def load_module_from_file(filepath, path=None, use_sys=True, extrapath=None):
+def load_module_from_file(filepath, path=None, use_sys=True):
"""Load a Python module from it's path.
:type filepath: str
@@ -276,7 +276,7 @@ def load_module_from_file(filepath, path=None, use_sys=True, extrapath=None):
:rtype: module
:return: the loaded module
"""
- modpath = modpath_from_file(filepath, extrapath)
+ modpath = modpath_from_file(filepath)
return load_module_from_modpath(modpath, path, use_sys)
@@ -327,20 +327,8 @@ def _get_relative_base_path(filename, path_to_check):
return None
-def modpath_from_file_with_callback(filename, extrapath=None, is_package_cb=None):
+def modpath_from_file_with_callback(filename, is_package_cb=None):
filename = os.path.expanduser(_path_from_filename(filename))
-
- if extrapath is not None:
- for path_ in itertools.chain(map(_canonicalize_path, extrapath), extrapath):
- path = os.path.abspath(path_)
- if not path:
- continue
- submodpath = _get_relative_base_path(filename, path)
- if not submodpath:
- continue
- if is_package_cb(path, submodpath[:-1]):
- return extrapath[path_].split(".") + submodpath
-
for path in itertools.chain(map(_canonicalize_path, sys.path), sys.path):
path = _cache_normalize_path(path)
if not path:
@@ -356,19 +344,14 @@ def modpath_from_file_with_callback(filename, extrapath=None, is_package_cb=None
)
-def modpath_from_file(filename, extrapath=None):
- """given a file path return the corresponding split module's name
- (i.e name of a module or package split on '.')
+def modpath_from_file(filename):
+ """Get the corresponding split module's name from a filename
+
+ This function will return the name of a module or package split on `.`.
:type filename: str
:param filename: file's path for which we want the module's name
- :type extrapath: dict
- :param extrapath:
- optional extra search path, with path as key and package name for the path
- as value. This is usually useful to handle package split in multiple
- directories using __path__ trick.
-
:raise ImportError:
if the corresponding module's name has not been found
@@ -376,7 +359,7 @@ def modpath_from_file(filename, extrapath=None):
:rtype: list(str)
:return: the corresponding split module's name
"""
- return modpath_from_file_with_callback(filename, extrapath, check_modpath_has_init)
+ return modpath_from_file_with_callback(filename, check_modpath_has_init)
def file_from_modpath(modpath, path=None, context_file=None):