Skip to content

Commit

Permalink
Resolve symlinks in the import path
Browse files Browse the repository at this point in the history
  • Loading branch information
keichi committed Nov 18, 2021
1 parent 30711bc commit 8d4ea3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ What's New in astroid 2.8.6?
============================
Release date: TBA

* Resolve symlinks in the import path
Fixes inference error when the import path includes symlinks (e.g. Python
installed on macOS via Homebrew).

Closes #823
Closes PyCQA/pylint#4759
Closes PyCQA/pylint#4798


What's New in astroid 2.8.5?
Expand Down
9 changes: 2 additions & 7 deletions astroid/modutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,7 @@ class NoSourceFile(Exception):


def _normalize_path(path):
return os.path.normcase(os.path.abspath(path))


def _canonicalize_path(path):
return os.path.realpath(os.path.expanduser(path))
return os.path.normcase(os.path.realpath(os.path.expanduser(path)))


def _path_from_filename(filename, is_jython=IS_JYTHON):
Expand Down Expand Up @@ -298,9 +294,8 @@ 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))
for pathname in itertools.chain(
path or [], map(_canonicalize_path, sys.path), sys.path
path or [], map(_cache_normalize_path, sys.path), sys.path
):
pathname = _cache_normalize_path(pathname)
if not pathname:
continue
modpath = _get_relative_base_path(filename, pathname)
Expand Down

0 comments on commit 8d4ea3a

Please sign in to comment.