Fix checkpoint delete crashing on valid tinker:// paths due to list command shadowing builtin#46
Open
lcrh wants to merge 1 commit into
Open
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
tinker checkpoint delete -y tinker://<run-id>/weights/<id>crashes for any well-formedtinker://path:(Malformed paths fail earlier at the
startswith("tinker://")check, so only valid paths trigger this.)Root cause
In
src/tinker/cli/commands/checkpoint.py, thelistsubcommand is defined as a plaindef list(...)at module scope. That rebinds the module-global namelistto the Click command object, shadowing thelistbuiltin for the entire module. Any builtinlist(...)call in the module then resolves to the Click command instead of constructing a list.The
deletecommand's no---run-idbranch does:This invokes the
listcommand with the path tuple as argv, which Click rejects as an unexpected extra argument. (The--run-idbranch uses a comprehension, so it was unaffected.)The same shadowing also silently affects the
list(...)calls in_export_checkpoint_to_hubandpush_hf— so this is a class of bug, not a single call site.Fix
Rename the function to
list_checkpointsand preserve the CLI name with@cli.command("list"). This restores thelistbuiltin 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.Verification
tinker checkpoint listcommand name unchanged; group still exposeslistanddelete.listbuiltin is no longer shadowed at module scope.tests/test_checkpoint_delete.pypasses (20 tests);ruff checkclean.🤖 Generated with Claude Code