API Reference
This page is auto-generated from Python docstrings.
pup_clean
pup-clean package.
__main__
Run as a module.
base
Base package.
types
Typed records.
CleanupTarget
dataclass
A known disposable repository target.
Source code in src/pup_clean/base/types.py
19 20 21 22 23 24 | |
cli
Command-line interface.
This module parses arguments and dispatches repository cleanup behavior.
Commands: uv run pup-clean uv run pup-clean --delete
Equivalent uvx usage after release: uvx pup-clean uvx pup-clean@latest uvx pup-clean --delete
build_parser
build_parser() -> argparse.ArgumentParser
Build the argument parser.
Source code in src/pup_clean/cli.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
main
main(argv: Sequence[str] | None = None) -> int
Run the command-line interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
argv
|
Sequence[str] | None
|
Optional command-line arguments. If None, uses sys.argv. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Exit code from the clean command. |
Source code in src/pup_clean/cli.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
commands
Command modules.
Each command module exposes a stable run(...) -> int entry point.
The CLI parser lives in pup_clean.cli. Behavior lives here.
clean
Clean known disposable and source-generated repository artifacts.
run
run(
*,
root: Path | None = None,
delete: bool = False,
paths: tuple[Path, ...] = (),
) -> int
Preview or remove known disposable and generated repository artifacts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path | None
|
Repository root. If None, detect the current repository root. |
None
|
delete
|
bool
|
Whether to delete detected cleanup targets. False means dry-run only. |
False
|
paths
|
tuple[Path, ...]
|
Optional repository-relative cleanup targets. When provided, operate only on detected targets matching these paths. |
()
|
Returns:
| Type | Description |
|---|---|
int
|
Process exit code. |
Source code in src/pup_clean/commands/clean.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
delete_terminal
Terminal reporting.
print_cleanup_plan
print_cleanup_plan(
context: RepositoryContext,
targets: Sequence[CleanupTarget],
*,
delete: bool,
) -> None
Print the repository cleanup plan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
RepositoryContext
|
The repository context. |
required |
targets
|
Sequence[CleanupTarget]
|
The list of cleanup targets. |
required |
delete
|
bool
|
Whether to actually delete the targets or just perform a dry run. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in src/pup_clean/delete_terminal.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
inspect_generated
Discover generated artifacts by inspecting Python source code.
This module statically inspects Python source files under src/ and finds
paths passed to known data-writing, database-creation, and image-writing
operations.
The purpose is to identify artifacts created by running a project so that pup-clean can remove generated outputs.
Only statically resolvable generated file paths are returned. Containing directories are not cleanup targets.
discover_generated_paths
discover_generated_paths(root: Path) -> tuple[Path, ...]
Discover generated data artifacts referenced by project source code.
Python files under src/ are parsed using the AST. Known data-writing
operations are inspected and statically resolvable output paths are
returned.
A path is returned only when it can be resolved from source code with sufficient confidence. Dynamic or ambiguous paths are ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
Repository root. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Path, ...]
|
Repository-relative paths for discovered generated artifacts. |
Source code in src/pup_clean/inspect_generated.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |