Skip to content

Commit

Permalink
fix the documentation and the error message of modpath_from_file (pyl…
Browse files Browse the repository at this point in the history
…int-dev#2532)

The doc should clarify that the search will always include sys.path.

The error message should reflect the actual paths used for checking.
  • Loading branch information
temyurchenko authored Aug 30, 2024
1 parent 5210e61 commit 37b6c0d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions astroid/modutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ def modpath_from_file_with_callback(
return modpath

raise ImportError(
"Unable to find module for {} in {}".format(filename, ", \n".join(sys.path))
"Unable to find module for {} in {}".format(
filename, ", \n".join(paths_to_check)
)
)


Expand All @@ -305,8 +307,8 @@ def modpath_from_file(filename: str, path: Sequence[str] | None = None) -> list[
:param filename: file's path for which we want the module's name
:type Optional[List[str]] path:
Optional list of path where the module or package should be
searched (use sys.path if nothing or None is given)
Optional list of paths where the module or package should be
searched, additionally to sys.path
:raise ImportError:
if the corresponding module's name has not been found
Expand Down

0 comments on commit 37b6c0d

Please sign in to comment.