Fix cleanup of app binaries for venvs without pipx_metadata.json #651
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
docs/changelog.md
Summary of changes
Found this code bug with
mypy --warn-unreachable
.This PR fixes a bug with
pipx uninstall
that would leave app binaries leftover in~/.local/bin
if the venv has no metadata file.We were testing the wrong object to determine if metadata was present in
uninstall.py
.venv.pipx_metadata.main_package
is in fact always notNone
, (it's alwaysPackageInfo
) so the else (for missing metadata case) was impossible to execute. Thus the special cleanup code for the non-metadata case to remove app binaries never executed.I fixed it by changing the test for
None
to the objectvenv.pipx_metadata.main_package.package
.In addition, I updated
venv.get_venv_metadata_for_package
to add its currently-necessary second argument. (This code must have been unreachable for a while to not get flagged that it is missing an argument.)Test plan
Tested by running
pipx install pycowsay rm ~/.local/pipx/venvs/pycowsay/pipx_metadata.json pipx uninstall pycowsay
This PR:
pipx 0.16.1.0