Skip to content

Commit

Permalink
Simplify was_installed_by_pip() (#6616)
Browse files Browse the repository at this point in the history
This uses `get_installer()` to reduce code duplication.
  • Loading branch information
pradyunsg authored Jun 16, 2019
2 parents bc731c7 + 2ffbf88 commit 8228407
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/6533.trivial
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Override the definition of the function was_installed_by_pip (src\pip\_internal\utils\outdated.py) too specific with a more general alternative
4 changes: 2 additions & 2 deletions src/pip/_internal/utils/outdated.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pip._internal.utils.compat import WINDOWS
from pip._internal.utils.filesystem import check_path_owner
from pip._internal.utils.misc import ensure_dir, get_installed_version
from pip._internal.utils.packaging import get_installer
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
Expand Down Expand Up @@ -85,8 +86,7 @@ def was_installed_by_pip(pkg):
"""
try:
dist = pkg_resources.get_distribution(pkg)
return (dist.has_metadata('INSTALLER') and
'pip' in dist.get_metadata_lines('INSTALLER'))
return "pip" == get_installer(dist)
except pkg_resources.DistributionNotFound:
return False

Expand Down

0 comments on commit 8228407

Please sign in to comment.