Skip to content

Conversation

ever3001
Copy link

  • I have added a news fragment under changelog.d/ (if the patch affects the end users)

Summary of changes

This PR adds a new pipx clean command that allows users to remove pipx data directories. The command provides flexible cleanup options:

Key features

  • Selective cleanup: Clean specific components using --cache, --logs, --trash, or --venvs flags
  • Full cleanup: Remove all pipx data when no flags are specified (resets to fresh installation state)
  • Safety confirmation: Requires user confirmation before cleanup (can be bypassed with --force)

This PR solves issues #1606 and #1681.

Test plan

Local tests

# Test manual cleanup
pipx install pycowsay
pipx clean --force
pipx list  # Verify pycowsay is still installed

# Test selective cleanup
pipx install pycowsay
pipx clean --cache --force
pipx clean --logs --force
pipx clean --trash --force
pipx clean --venvs --force
pipx list  # Verify pycowsay is still installed

# Execute unit tests
nox -s tests -- tests/test_clean.py

Unit tests

  • Added unit tests in tests/test_clean.py to cover various scenarios of the pipx clean command, including:
    • Cleaning individual components (cache, logs, trash, venvs)
    • Full cleanup
    • Error handling during cleanup

Github Actions CI

I run the workflow tests in my fork to ensure all tests pass in CI.

Link to workflow run: tests #5

ever3001 added 3 commits October 11, 2025 17:04
The new command supports selective cleanup with `--cache`, `--logs`,
`--trash`, and `--venvs` flags to remove specific components. Running
`pipx clean` without flags performs a full cleanup, removing all pipx
data and resetting to a fresh installation state.
Configured mypy to recognize pytest library by adding pytest plugin to mypy configuration. This allows mypy to properly type-check pytest fixtures and decorators, eliminating the need for "type: ignore" comments in test files.
@ever3001 ever3001 force-pushed the ever3001/feature/add_clean_option branch from 13bc7cf to f713984 Compare October 11, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant