From 65b85822331edc0963440ddc3be31d3960a213d5 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Mon, 22 Jan 2024 00:37:00 -0500 Subject: [PATCH] Revert "Reduce complexity here with pathlib" This reverts commit c58ea388d72c80f71fb5f53204787ccb9f2b3675. --- pipenv/vendor/pythonfinder/models/path.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/pipenv/vendor/pythonfinder/models/path.py b/pipenv/vendor/pythonfinder/models/path.py index 2f11a8d7ca..ce0dcd297f 100644 --- a/pipenv/vendor/pythonfinder/models/path.py +++ b/pipenv/vendor/pythonfinder/models/path.py @@ -15,7 +15,6 @@ DefaultDict, Generator, Iterator, - Union, ) from ..environment import ( @@ -312,28 +311,20 @@ def _setup_pyenv(self) -> SystemPath: self._register_finder("pyenv", pyenv_finder) return self - def get_path(self, path: Union[str, Path]) -> Union[PythonFinder, PathEntry]: + def get_path(self, path) -> PythonFinder | PathEntry: if path is None: raise TypeError("A path must be provided in order to generate a path entry.") - - # Convert path to pathlib.Path object if it's a string - path = Path(path) if isinstance(path, str) else path - - # Try to get the PathEntry or PythonFinder from the paths dictionary + path = ensure_path(path) _path = self.paths.get(path) - - # If not found, check if the path exists and is part of the path_order - if not _path and str(path) in self.path_order and path.exists(): + if not _path: + _path = self.paths.get(path.as_posix()) + if not _path and path.as_posix() in self.path_order and path.exists(): _path = PathEntry.create( - path=path.resolve(), # resolve() method will give the absolute path - is_root=True, - only_python=self.only_python + path=path.absolute(), is_root=True, only_python=self.only_python ) - self.paths[str(path)] = _path # Store the PathEntry or PythonFinder in paths - + self.paths[path.as_posix()] = _path if not _path: raise ValueError(f"Path not found or generated: {path!r}") - return _path def _get_paths(self) -> Generator[PythonFinder | PathEntry, None, None]: