Skip to content

feat(operations.flatpak): add purge option to remove application data - #2114

Open
samuelmalpin wants to merge 2 commits into
pyinfra-dev:3.xfrom
samuelmalpin:add/purge
Open

samuelmalpin wants to merge 2 commits into
pyinfra-dev:3.xfrom
samuelmalpin:add/purge

Conversation

@samuelmalpin

@samuelmalpin samuelmalpin commented Nov 25, 2026 •

Copy link
Copy Markdown

This adds a purge option to flatpak.packages. If you remove a package with
present=False and purge=True, it runs flatpak uninstall with --delete-data,
so the app's data gets deleted too.

It works for both system and user installs, and it's False by default.

I added tests for both install modes.

  • Pull request is based on the default branch (3.x at this time)
  • Pull request includes tests for any new/updated operations/facts
  • Pull request includes documentation for any new/updated operations/facts
  • Tests pass (see scripts/dev-test.sh)
  • Type checking & code style passes (see scripts/dev-lint.sh)
  • Pull request title follows the
    conventional commits format

Copilot AI balanced review requested due to automatic review settings November 25, 2026 14:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Purging skips residual data for already-uninstalled Flatpak applications because cleanup is limited to installed packages; independent cleanup and absent-application test coverage are needed.

1 open issue
What changed in this PR

Adds an opt-in purge parameter to pyinfra’s Flatpak package operation, allowing uninstall commands to request application-data deletion.

Changes:

  • Adds purge=False and documents the parameter.
  • Appends Flatpak’s --delete-data flag when purging packages selected for removal.
  • Adds command-generation fixtures for default and user installations.
File Description
tests/​operations/​flatpak.packages/​purge_packages.json Tests purge command generation for the default installation.
tests/​operations/​flatpak.packages/​purge_packages_user.json Tests purge command generation with --user.
src/​pyinfra/​operations/​flatpak.py Adds and documents the purge parameter and uninstall flag.

Review effort: Balanced

if remove_packages:
yield StringCommand(
f"flatpak uninstall --noninteractive{' --user' if user else ''}",
f"flatpak uninstall --noninteractive{' --user' if user else ''}{' --delete-data' if purge else ''}",
Adding --purge flag to remove application data
@samuelmalpin samuelmalpin changed the title feat(flatpak): New purge feature Adding --purge flag to remove application data feat(operations.flatpak): New purge feature Adding --purge flag to remove application data Nov 25, 2026
@wowi42 wowi42 added new feature operations Issues with operations. labels Nov 25, 2026

@Fizzadar Fizzadar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the docs example inline, otherwise good!

Comment thread src/pyinfra/operations/flatpak.py Resolved
Comment thread src/pyinfra/operations/flatpak.py Outdated
+ remote: Source from which to install the application or runtime
+ present: whether the package should be installed
+ user: use the current user's installation instead of Flatpak's default
+ purge: delete application data

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: worth saying this only applies when present=False?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you're right i will precise it

Co-authored-by: Nick Mills-Barrett <nick@fizzadar.com>

@wowi42 wowi42 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to me. purge=True maps to Flatpak's --delete-data, with system and user fixtures. Please fill in the PR body and test checklist before merge.

@samuelmalpin samuelmalpin changed the title feat(operations.flatpak): New purge feature Adding --purge flag to remove application data feat(operations.flatpak): add purge option to remove application data Dec 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature operations Issues with operations.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants