Skip to content

Commit

Permalink
Don't use check_if_exists in InstallRequirement.uninstall (pypa#7422)
Browse files Browse the repository at this point in the history
Previously InstallRequirement.uninstall was using
InstallRequirement.check_if_exists, which is a very overloaded
function with several callers that operate at different phases in
pip processing, not to mention that it mutates InstallRequirement itself.

Now we don't use that function for InstallRequirement.uninstall.

There should be no behavior change here.
  • Loading branch information
chrahunt committed Dec 3, 2019
1 parent 830e29e commit d3419a4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/pip/_internal/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,8 @@ def update_editable(self, obtain=True):
% (self.link, vc_type))

# Top-level Actions
def uninstall(self, auto_confirm=False, verbose=False,
use_user_site=False):
# type: (bool, bool, bool) -> Optional[UninstallPathSet]
def uninstall(self, auto_confirm=False, verbose=False):
# type: (bool, bool) -> Optional[UninstallPathSet]
"""
Uninstall the distribution currently satisfying this requirement.
Expand All @@ -694,10 +693,12 @@ def uninstall(self, auto_confirm=False, verbose=False,
linked to global site-packages.
"""
if not self.check_if_exists(use_user_site):
assert self.req
try:
dist = pkg_resources.get_distribution(self.req.name)
except pkg_resources.DistributionNotFound:
logger.warning("Skipping %s as it is not installed.", self.name)
return None
dist = self.satisfied_by or self.conflicts_with

uninstalled_pathset = UninstallPathSet.from_dist(dist)
uninstalled_pathset.remove(auto_confirm, verbose)
Expand Down

0 comments on commit d3419a4

Please sign in to comment.