From 52a6318c88e30ba841fd1cffeeb21990e9f91454 Mon Sep 17 00:00:00 2001 From: Maximillian Bensch Date: Wed, 11 Jan 2023 10:17:14 +0100 Subject: [PATCH] message_about_scripts_not_on_PATH: use pathlib also for parent_dir and script_name directly --- src/pip/_internal/operations/install/wheel.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pip/_internal/operations/install/wheel.py b/src/pip/_internal/operations/install/wheel.py index 1f5af208f54..cae01f3726b 100644 --- a/src/pip/_internal/operations/install/wheel.py +++ b/src/pip/_internal/operations/install/wheel.py @@ -136,10 +136,10 @@ def message_about_scripts_not_on_PATH(scripts: Sequence[str]) -> Optional[str]: return None # Group scripts by the path they were installed in - grouped_by_dir: Dict[str, Set[str]] = collections.defaultdict(set) + grouped_by_dir: Dict[Path, Set[str]] = collections.defaultdict(set) for destfile in scripts: - parent_dir = os.path.dirname(destfile) - script_name = os.path.basename(destfile) + parent_dir = Path(destfile).parent.resolve() + script_name = Path(destfile).name grouped_by_dir[parent_dir].add(script_name) # We don't want to warn for directories that are on PATH. @@ -149,10 +149,10 @@ def message_about_scripts_not_on_PATH(scripts: Sequence[str]) -> Optional[str]: # If an executable sits with sys.executable, we don't warn for it. # This covers the case of venv invocations without activating the venv. not_warn_dirs.append(Path(sys.executable).parent.resolve()) - warn_for: Dict[str, Set[str]] = { + warn_for: Dict[Path, Set[str]] = { parent_dir: scripts for parent_dir, scripts in grouped_by_dir.items() - if Path(parent_dir).resolve() not in not_warn_dirs + if parent_dir not in not_warn_dirs } if not warn_for: return None