Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify InstallRequirement.uninstall #7422

Merged
merged 26 commits into from
Dec 3, 2019
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ba990f5
Remove use_user_site argument from uninstall
chrahunt Dec 3, 2019
5ee8572
Make a copy of check_if_exists for uninstall
chrahunt Dec 3, 2019
42bbdb9
Inline constant argument in check_if_exists_uninstall
chrahunt Dec 3, 2019
d1b4b4a
Remove dead code in check_if_exists_uninstall
chrahunt Dec 3, 2019
fe433e0
Remove local variable in check_if_exists_uninstall
chrahunt Dec 3, 2019
8205ee0
Remove unnecessary check in check_if_exists_uninstall
chrahunt Dec 3, 2019
7a34802
Add uninstall dist getter wrapper
chrahunt Dec 3, 2019
a4a0243
Inline wrapper into check_with_exists_uninstall
chrahunt Dec 3, 2019
5ec365b
Assert satisfied_by is None in UninstallCommand
chrahunt Dec 3, 2019
ddf7eb1
Assert satisfied_by is None when uninstalling during install
chrahunt Dec 3, 2019
cf71d57
Propagate assertions
chrahunt Dec 3, 2019
20adf2f
Enforce that satisfied_by and conflicts_with aren't used
chrahunt Dec 3, 2019
660713c
Inline and simplify condition
chrahunt Dec 3, 2019
7d30b6d
Inline return value
chrahunt Dec 3, 2019
71c7e58
Simplify condition
chrahunt Dec 3, 2019
58f6d31
Duplicate function return value for else branch
chrahunt Dec 3, 2019
0f03e3f
Remove redundant part of conditional
chrahunt Dec 3, 2019
926ffb7
Collapse if/else with duplicate branches
chrahunt Dec 3, 2019
65d27f9
Inline return value
chrahunt Dec 3, 2019
e698bc2
Inline assertion
chrahunt Dec 3, 2019
7f63760
Inline return value
chrahunt Dec 3, 2019
5e2017d
Remove unnecessary member value enforcement
chrahunt Dec 3, 2019
0b14efb
Only use name to find existing requirement for uninstall
chrahunt Dec 3, 2019
14e377e
Remove unused variable
chrahunt Dec 3, 2019
b93a384
Inline check_if_exists_uninstall into uninstall
chrahunt Dec 3, 2019
e5d4b1c
Remove leftover asserts
chrahunt Dec 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -678,9 +678,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 @@ -693,10 +692,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