Skip to content

Commit

Permalink
cache: Do not raise error when there are no files to remove
Browse files Browse the repository at this point in the history
Instead log a warning and continue (to log that we removed 0 files)
  • Loading branch information
Noah Gorny committed Sep 11, 2021
1 parent 48dc9f4 commit 61cc712
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions news/10459.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Do not raise error when there are no files to remove with ``pip cache purge/remove``.
Instead log a warning and continue (to log that we removed 0 files).
2 changes: 1 addition & 1 deletion src/pip/_internal/commands/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def remove_cache_items(self, options: Values, args: List[Any]) -> None:
files += self._find_http_files(options)

if not files:
raise CommandError("No matching packages")
logger.warning("No matching packages")

for filename in files:
os.unlink(filename)
Expand Down

0 comments on commit 61cc712

Please sign in to comment.