Skip to content

Fix checkpoint delete crashing on valid tinker:// paths due to list command shadowing builtin#46

Open
lcrh wants to merge 1 commit into
thinking-machines-lab:mainfrom
lcrh:fix/checkpoint-delete-list-shadowing
Open

Fix checkpoint delete crashing on valid tinker:// paths due to list command shadowing builtin#46
lcrh wants to merge 1 commit into
thinking-machines-lab:mainfrom
lcrh:fix/checkpoint-delete-list-shadowing

Conversation

@lcrh
Copy link
Copy Markdown

@lcrh lcrh commented May 30, 2026

Bug

tinker checkpoint delete -y tinker://<run-id>/weights/<id> crashes for any well-formed tinker:// path:

Error: Got unexpected extra argument (tinker://<run-id>/weights/<id>)

(Malformed paths fail earlier at the startswith("tinker://") check, so only valid paths trigger this.)

Root cause

In src/tinker/cli/commands/checkpoint.py, the list subcommand is defined as a plain def list(...) at module scope. That rebinds the module-global name list to the Click command object, shadowing the list builtin for the entire module. Any builtin list(...) call in the module then resolves to the Click command instead of constructing a list.

The delete command's no---run-id branch does:

paths_to_delete = list(checkpoint_paths)

This invokes the list command with the path tuple as argv, which Click rejects as an unexpected extra argument. (The --run-id branch uses a comprehension, so it was unaffected.)

The same shadowing also silently affects the list(...) calls in _export_checkpoint_to_hub and push_hf — so this is a class of bug, not a single call site.

Fix

Rename the function to list_checkpoints and preserve the CLI name with @cli.command("list"). This restores the list builtin across the module and prevents the whole class of bug. No code references the command by its Python symbol (it is registered with the Click group by name and lazy-loaded), so the rename is safe.

-@cli.command()
+@cli.command("list")
 @click.option("--run-id", help="Training run ID")
 ...
-def list(cli_context: CLIContext, run_id: str | None, limit: int) -> None:
+def list_checkpoints(cli_context: CLIContext, run_id: str | None, limit: int) -> None:

Verification

  • tinker checkpoint list command name unchanged; group still exposes list and delete.
  • list builtin is no longer shadowed at module scope.
  • tests/test_checkpoint_delete.py passes (20 tests); ruff check clean.

🤖 Generated with Claude Code

…t` command shadowing builtin

The `list` checkpoint subcommand was defined as `def list(...)` at module
scope, which rebound the module-global name `list` to the Click command
object and shadowed the `list` builtin for the entire module. Builtin
`list(...)` calls in the same module then invoked the Click command instead
of constructing a list.

The most visible symptom: `tinker checkpoint delete -y tinker://<run-id>/weights/<id>`
hit `paths_to_delete = list(checkpoint_paths)` in the no-`--run-id` branch,
which invoked the `list` command with the path tuple as argv and failed with
`Error: Got unexpected extra argument (tinker://...)` for any well-formed path.
The same shadowing also silently affected the `list(...)` calls in
`_export_checkpoint_to_hub` and `push_hf`.

Rename the function to `list_checkpoints` and preserve the CLI name via
`@cli.command("list")`, restoring the builtin and preventing the whole class
of bug.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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