From a067d728097afbcaa32265376b8e87cb3d05285c Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Fri, 22 Apr 2022 15:56:57 +0100 Subject: [PATCH] Add an early return with comment if pip wasn't installed by pip This addresses a review comment around the code style, and makes it possible to provide additonal context in the comment. --- src/pip/_internal/self_outdated_check.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pip/_internal/self_outdated_check.py b/src/pip/_internal/self_outdated_check.py index 26d3508d06d..d2f1213ed78 100644 --- a/src/pip/_internal/self_outdated_check.py +++ b/src/pip/_internal/self_outdated_check.py @@ -193,11 +193,12 @@ def _self_version_check_logic( pip_installed_by_pip = was_installed_by_pip("pip") logger.debug("Was pip installed by pip? %s", pip_installed_by_pip) + if not pip_installed_by_pip: + return None # Only suggest upgrade if pip is installed by pip. local_version_is_older = ( local_version < remote_version and local_version.base_version != remote_version.base_version - and pip_installed_by_pip ) if local_version_is_older: return UpgradePrompt(old=str(local_version), new=remote_version_str)